function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $pathway = $app->getPathway(); $document = JFactory::getDocument(); $contentid = JRequest::getInt( 'id', 0 ); if ($user->id == 0) { TTools::redirectToLogin("index.php?option=com_adsmanager&view=expiration&id=$contentid"); } $contentmodel =$this->getModel( "content" ); $configurationmodel =$this->getModel( "configuration" ); $conf = $configurationmodel->getConfiguration(); $content = $contentmodel->getContent($contentid,false); if (($content == null)||($content->userid != $user->id)) $app->redirect( TRoute::_('index.php?option=com_adsmanager') ); $this->assignRef('content',$content); $document->setTitle( JText::_('ADSMANAGER_PAGE_EXPIRATION')); parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $pathway = $app->getPathway(); $document = JFactory::getDocument(); $usermodel =$this->getModel( "user" ); $configurationmodel =$this->getModel( "configuration" ); $fieldmodel =$this->getModel( "field" ); $userid = $user->id; if ($userid == 0) { TTools::redirectToLogin(TLink::getProfileLink()); } else { $conf = $configurationmodel->getConfiguration(); if ((COMMUNITY_BUILDER == 1)||(JOMSOCIAL == 1)) { $app->redirect( TLink::getProfileLink() ); } else { $fields = $usermodel->getProfileFields(); $plugins = $fieldmodel->getPlugins(); $field_values = $fieldmodel->getFieldValues(); foreach($fields as $field) { if ($field->cbfieldvalues != "-1") { /*get CB value fields */ $cbfieldvalues = $fieldmodel->getCBFieldValues($field->cbfieldvalues); $field_values[$field->fieldid] = $cbfieldvalues; } } $field = new JHTMLAdsmanagerField($conf,$field_values,"1",$plugins); $user = $usermodel->getProfile($userid); $this->assignRef('field',$field); $this->assignRef('fields',$fields); $this->assignRef('user',$user); } } $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('adsmanagercontent'); $event = new stdClass(); $results = $dispatcher->trigger('ADSonUserAfterForm', array ($user)); $event->onUserAfterForm = trim(implode("\n", $results)); $this->assignRef('event',$event); $document->setTitle( JText::_('ADSMANAGER_PAGE_TITLE')); parent::display($tpl); }
function getAdsmanagerUser($userid) { $db = JFactory::getDBO(); $sql = "SELECT username FROM #__users WHERE id = " . (int) $userid; $db->setQuery($sql); $result = $db->loadResult(); $result = TTools::stringURLSafe($result); $result = JString::substr($result, 0, 30); return $result; }
/** * No args just to be compliant with joomla API * @param unknown_type $src * @param unknown_type $orderingFilter * @param unknown_type $ignore */ function saveContent($src, $orderingFilter = '', $ignore = '') { $row = new JObject(); if ($this->id != 0) { $row->id = $this->id; } //new_ad $app = JFactory::getApplication(); if ($app->isAdmin() == true || $app->isAdmin() == false && @$this->new_ad == true) { $row->date_created = $this->date_created; $row->expiration_date = $this->expiration_date; $row->publication_date = $this->publication_date; } //In case of bindContent / update Ad, $this->published is not set if ($this->published !== null) { $row->published = $this->published; } $row->date_modified = date('Y-m-d H:i:s'); $row->userid = $this->userid; foreach ($this->data['fields'] as $name => $value) { if (is_array($value)) { $v = ',' . implode(',', $value) . ','; } else { $v = $value; } $row->{$name} = $v; } $row->metadata_description = $this->metadata_description; $row->metadata_keywords = $this->metadata_keywords; //Insert new record. if ($this->id == 0) { $ret = $this->_db->insertObject('#__adsmanager_ads', $row); $contentid = (int) $this->_db->insertid(); } else { $ret = $this->_db->updateObject('#__adsmanager_ads', $row, 'id'); $contentid = $this->id; } // Category $query = "DELETE FROM #__adsmanager_adcat WHERE adid = {$contentid}"; $this->_db->setQuery($query); $this->_db->query(); foreach ($this->data['categories'] as $cat) { $query = "INSERT INTO #__adsmanager_adcat(adid,catid) VALUES ({$contentid},{$cat})"; $this->_db->setQuery($query); $this->_db->query(); $this->catid = $cat; } //Images $dir = JPATH_ROOT . "/images/com_adsmanager/ads/waiting/"; $dirfinal = JPATH_ROOT . "/images/com_adsmanager/ads/"; $current_images = json_decode($this->images); if ($current_images == null) { $current_images = array(); } if (!is_array($current_images)) { $current_images = get_object_vars($current_images); } foreach ($this->data['delimages'] as $image) { if (is_file(JPATH_ROOT . "/images/com_adsmanager/ads/" . $image->image)) { JFile::delete(JPATH_ROOT . "/images/com_adsmanager/ads/" . $image->image); } /* if(is_file(JPATH_ROOT."/images/com_adsmanager/ads/".$image->thumbnail)) { JFile::delete(JPATH_ROOT."/images/com_adsmanager/ads/".$image->thumbnail); } if(is_file(JPATH_ROOT."/images/com_adsmanager/ads/".$image->medium)) { @JFile::delete(JPATH_ROOT."/images/com_adsmanager/ads/".$image->medium); }*/ foreach ($current_images as $key => $img) { if ($img->index == $image->index) { unset($current_images[$key]); break; } } } if (!is_array($current_images)) { $current_images = get_object_vars($current_images); } sort($current_images); jimport('joomla.filter.output'); //True to force transliterate $imgtitle = TTools::stringURLSafe($row->ad_headline, true); if ($imgtitle == "") { $imgtitle = "image"; } foreach ($this->data['images'] as &$image) { $src = $dir . $image->image; $dest = $dirfinal . $imgtitle . "_" . $contentid . "_" . $image->index . ".jpg"; JFile::move($src, $dest); $image->image = $imgtitle . "_" . $contentid . "_" . $image->index . ".jpg"; /* $src =$dir.$image->thumbnail; $dest =$dirfinal.$imgtitle."_".$contentid."_".$image->index."_t.jpg"; JFile::move($src,$dest); $image->thumbnail = $imgtitle."_".$contentid."_".$image->index."_t.jpg"; $src =$dir.$image->medium; $dest =$dirfinal.$imgtitle."_".$contentid."_".$image->index."_m.jpg"; JFile::move($src,$dest); $image->medium = $imgtitle."_".$contentid."_".$image->index."_m.jpg";*/ $current_images[] = $image; } $orderlist = $this->data['orderimages']; $newlistimages = array(); /* foreach($orderlist as $o) { foreach($current_images as $image) { if ($image->index == $o) $newlistimages[] = $image; } }*/ $row = new JObject(); $row->id = $contentid; // $row->images = json_encode($newlistimages); // $this->images = $newlistimages; $ret = $this->_db->updateObject('#__adsmanager_ads', $row, 'id'); if (function_exists('savePaidAd')) { savePaidAd($this, $contentid); } $this->id = $contentid; $this->_db->setQuery("DELETE FROM #__adsmanager_pending_ads WHERE contentid=" . intval($contentid)); $this->_db->query(); $cache =& JFactory::getCache('com_adsmanager'); $cache->clean(); }
function _editcontent() { $this->setEditToolbar(JText::_("COM_ADSMANAGER") . " - " . JText::_("ADSMANAGER_EDIT_CONTENT")); $app = JFactory::getApplication(); $document = JFactory::getDocument(); $user = JFactory::getUser(); $confmodel = $this->getModel("Configuration"); $usermodel = $this->getModel("User"); $contentmodel = $this->getModel("Content"); $catmodel = $this->getModel("Category"); $fieldmodel = $this->getModel("Field"); $conf = $confmodel->getConfiguration(); if (!isset($conf->single_category_selection_type)) { $conf->single_category_selection_type = 'normal'; } $baseurl = JURI::root(); $document->addStyleSheet($baseurl . 'components/com_adsmanager/js/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css'); $document->addStyleSheet($baseurl . 'components/com_adsmanager/css/adsmanager.css'); $document->addScript($baseurl . 'components/com_adsmanager/js/plupload/plupload.full.js'); $document->addScript($baseurl . 'components/com_adsmanager/js/plupload/jquery.plupload.queue/jquery.plupload.queue.js'); $lang = JFactory::getLanguage(); $tag = $lang->getTag(); $tag = substr($tag, 0, strpos($tag, '-')); if (file_exists(JPATH_ROOT . "/components/com_adsmanager/js/plupload/i18n/{$tag}.js")) { $document->addScript($baseurl . "components/com_adsmanager/js/plupload/i18n/{$tag}.js"); } $this->assignRef('conf', $conf); $catid = JRequest::getInt('catid', 0); if ($catid != 0) { $category = $catmodel->getCategory($catid); $category->img = TTools::getCatImageUrl($catid, true); } else { $category = new stdClass(); $category->name = JText::_(""); $category->description = ""; $category->img = ""; } $this->assignRef('category', $category); $this->assignRef('catid', $catid); $fields = $fieldmodel->getFields(); $this->assignRef('fields', $fields); $field_values = $fieldmodel->getFieldValues(); foreach ($fields as $field) { if ($field->cbfieldvalues != "-1") { /*get CB value fields */ $cbfieldvalues = $fieldmodel->getCBFieldValues($field->cbfieldvalues); $field_values[$field->fieldid] = $cbfieldvalues; } } $this->assignRef('field_values', $field_values); $plugins = $fieldmodel->getPlugins(); $field = new JHTMLAdsmanagerField($conf, $field_values, "1", $plugins, "", $this->get('baseurl')); $this->assignRef('field', $field); $errorMsg = JRequest::getString('errorMsg', ""); $this->assignRef('errorMsg', $errorMsg); $users = $usermodel->getUsers(); $this->assignRef('users', $users); /* No need to user query, if errorMsg */ if ($errorMsg == "") { if (COMMUNITY_BUILDER == 0) { $profile = $usermodel->getProfile($user->id); } else { $profile = $usermodel->getCBProfile($user->id); } } $contentid = JRequest::getVar('cid', array(0), '', 'array'); JArrayHelper::toInteger($contentid, array(0)); $contentid = JRequest::getVar('id', $contentid[0], '', 'int'); // Update Ad ? if ($contentid > 0) { // edit ad $content = $contentmodel->getContent($contentid, false, 1); if ($content == null) { echo "Error Ad not found"; exit; } $content->ad_text = str_replace('<br/>', "\r\n", $content->ad_text); $isUpdateMode = 1; } else { // insert $content = new stdClass(); $content->published = 1; $isUpdateMode = 0; } $this->assignRef('content', $content); $this->assignRef('isUpdateMode', $isUpdateMode); $nbcats = $conf->nbcats; if (function_exists("getMaxCats")) { $nbcats = getMaxCats($conf->nbcats); } $this->assignRef('nbcats', $nbcats); if ($nbcats > 1) { $cats = $catmodel->getFlatTree(); } else { switch ($conf->single_category_selection_type) { default: case 'normal': case 'color': case 'combobox': $cats = $catmodel->getFlatTree(); break; case 'cascade': $cats = $catmodel->getCategoriesPerLevel(); break; } } $this->assignRef('cats', $cats); $nullobj = null; if ($errorMsg != "") { $this->assignRef('default', (object) JRequest::get('post')); } else { $this->assignRef('default', $nullobj); } if ($conf->submission_type == 2 && $user->id == "0") { $this->assignRef('warning_text', ADSMANAGER_WARNING_NEW_AD_NO_ACCOUNT . "<br/>"); } switch ($errorMsg) { case "bad_password": $this->assignRef('error_text', JText::_('ADSMANAGER_BAD_PASSWORD') . "<br />"); break; case "email_already_used": $this->assignRef('error_text', JText::_('ADSMANAGER_EMAIL_ALREADY_USED') . "<br />"); break; case "file_too_big": $this->assignRef('error_text', JText::_('ADSMANAGER_FILE_TOO_BIG') . "<br />"); } if ($conf->submission_type == 0 && $user->id == 0) { $this->assignRef('account_creation', 1); } }
function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $pathway = $app->getPathway(); $document = JFactory::getDocument(); $contentmodel =$this->getModel( "content" ); $catmodel =$this->getModel( "category" ); $positionmodel =$this->getModel( "position" ); $fieldmodel =$this->getModel( "field" ); $configurationmodel =$this->getModel( "configuration" ); // Get the parameters of the active menu item $menus = $app->getMenu(); $menu = $menus->getActive(); $conf = $configurationmodel->getConfiguration(); $catid = JRequest::getInt( 'catid', 0 ); if ($catid != "0") { $category = $catmodel->getCategory($catid); $category->img = TTools::getCatImageUrl($catid,true); } else { $category = new stdClass(); $category->name = JText::_("ADSMANAGER_ALL_ADS"); $category->description = ""; $category->img = ""; } $rootid = JRequest::getInt('rootid',0); $pathlist = $catmodel->getPathList($catid,'read',$rootid); $this->assignRef('pathlist',$pathlist); $positions = $positionmodel->getPositions(); $fDisplay = $fieldmodel->getFieldsbyPositions(); $field_values = $fieldmodel->getFieldValues(); $contentid = JRequest::getInt( 'id', 0 ); $content = $contentmodel->getContent($contentid,false); if (($content->published == false)&&($content->userid != $user->id)) { if (ADSMANAGER_SPECIAL == 'sale') { require_once(JPATH_ROOT.'/administrator/components/com_sale/models/configuration.php'); $model = new SaleModelConfiguration(); $saleconf = $model->getConfiguration(); if ($content->userid != $saleconf->userid) { $app->redirect( TRoute::_('index.php?option=com_adsmanager&view=list&catid='.$catid)); } //Display Ad } else if (ADSMANAGER_SPECIAL == 'barter') { } else { //JError::raiseError(404, JText::_("Page Not Found")); $app->redirect( TRoute::_('index.php?option=com_adsmanager&view=list&catid='.$catid)); } } if ($content == null) $app->redirect( JRoute::_('index.php?option=com_adsmanager&view=front&status=error'), JText::_('ADSMANAGER_ADS_NO_RIGHT'),'message' ); if($user->guest == false){ $favorites = $contentmodel->getFavorites($user->id); } else { $favorites = array(); } $this->assignRef('favorites',$favorites); $showContact = TPermissions::checkRightContact(); $this->assignRef('showContact',$showContact); $this->assignRef('list_name',$category->name); $this->assignRef('list_img',$category->img); $this->assignRef('list_description',$category->description); $this->assignRef('positions',$positions); $this->assignRef('fDisplay',$fDisplay); $this->assignRef('conf',$conf); $this->assignRef('userid',$user->id); $fields = $fieldmodel->getFields(); $this->assignRef('fields',$fields); $document->setTitle( JText::_('ADSMANAGER_PAGE_TITLE')." ".JText::_($category->name)." - ".$content->ad_headline); //set breadcrumbs $pathlist = $catmodel->getPathList($catid,'read',$rootid); $nb = count($pathlist); for ($i = $nb - 1 ; $i >=0;$i--) { $pathway->addItem($pathlist[$i]->text, $pathlist[$i]->link); } // need to be before getMultiLangText $plugins = $fieldmodel->getPlugins(); if (ADSMANAGER_SPECIAL == "abrivac") { $pathway->addItem(getMultiLangText($content->ad_headline), "#"); } else { $pathway->addItem($content->ad_headline, "#"); } $field = new JHTMLAdsmanagerField($conf,$field_values,'1',$plugins); $this->assignRef('field',$field); $general = new JHTMLAdsmanagerGeneral($catid,$conf,$user); $this->assignRef('general',$general); // // Process the content plugins. // $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('adsmanagercontent'); $results = $dispatcher->trigger('ADSonContentPrepare', array ($content)); $event = new stdClass(); $results = $dispatcher->trigger('ADSonContentAfterTitle', array ($content)); $event->onContentAfterTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('ADSonContentBeforeDisplay', array ($content)); $event->onContentBeforeDisplay = trim(implode("\n", $results)); $results = $dispatcher->trigger('ADSonContentAfterDisplay', array ($content)); $event->onContentAfterDisplay = trim(implode("\n", $results)); $content->event = $event; $this->assignRef('content',$content); if ($conf->metadata_mode == 'automatic') { if (ADSMANAGER_SPECIAL == "abrivac") { $content->metadata_description = getMultiLangText($content->ad_description); $content->metadata_keywords = str_replace(" ",",",getMultiLangText($content->ad_headline)); } else { $content->metadata_description = $content->ad_text; $content->metadata_keywords = str_replace(" ",",",$content->ad_headline); } } if($conf->image_display == 'jssor') { $tpl = 'jssor'; } parent::display($tpl); }
} ?> </div> <?php } echo $this->content->event->onContentBeforeDisplay; if (@$conf->print == 1) { ?> <div class="text-right"> <?php if (JRequest::getInt('print', 0) == 1) { echo TTools::print_screen(); } else { $url = "index.php?option=com_adsmanager&view=details&catid=" . $this->content->catid . "&id=" . $this->content->id; echo TTools::print_popup($url); } ?> </div> <?php } ?> <div class="<?php echo $classcontent; ?> adsmanager-details row-fluid"> <div class="span12 page-header"> <div class="span8"> <h1 class="no-margin-top"> <?php if (isset($this->fDisplay[1])) {
function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $pathway = $app->getPathway(); $document = JFactory::getDocument(); if ($user->id == 0) { TTools::redirectToLogin(TLink::getMyFavoritesLink()); return; } $contentmodel =$this->getModel( "content" ); $catmodel =$this->getModel( "category" ); $positionmodel =$this->getModel( "position" ); $columnmodel =$this->getModel( "column" ); $fieldmodel =$this->getModel( "field" ); $usermodel =$this->getModel( "user" ); $configurationmodel =$this->getModel( "configuration" ); $uri = JFactory::getURI(); $this->requestURL = $uri->toString(); // Get the parameters of the active menu item $menus = $app->getMenu(); $menu = $menus->getActive(); $conf = $configurationmodel->getConfiguration(); jimport( 'joomla.session.session' ); $currentSession = JSession::getInstance('none',array()); $currentSession->set("search_fields",""); $currentSession->set("searchfieldscatid",0); $currentSession->set("searchfieldssql"," 1 "); $currentSession->set("tsearch",""); $filters = array(); $tsearch = JRequest::getVar( 'tsearch', ''); if ($tsearch != "") { $filters['search'] = $tsearch; } $this->assignRef('tsearch',$tsearch); $username = $usermodel->getUser($user->id); $orderfields = $fieldmodel->getOrderFields(0); $this->assignRef('orders',$orderfields); $limitstart = JRequest::getInt("limitstart",0); $limit = $app->getUserStateFromRequest('com_adsmanager.front_ads_per_page','limit',$conf->ads_per_page, 'int'); $order = $app->getUserStateFromRequest('com_adsmanager.front_content.order','order',0,'int'); $orderdir = $app->getUserStateFromRequest('com_adsmanager.front_content.orderid','orderdir','DESC'); $orderdir = strtoupper($orderdir); if (($orderdir != "DESC") && ($orderdir != "ASC")) { $orderdir = "DESC"; } $filter_order = $contentmodel->getFilterOrder($order); $filter_order_dir = $orderdir; $this->assignRef('order',$order); $this->assignRef('orderdir',$orderdir); $total = $contentmodel->getNbContents($filters,0,$user->id); $contents = $contentmodel->getContents($filters,$limitstart, $limit,$filter_order,$filter_order_dir,0,$user->id); jimport('joomla.html.pagination'); $pagination = new JPagination($total, $limitstart, $limit); $this->assignRef('pagination',$pagination); $this->assignRef('list_name',$name); $this->assignRef('contents',$contents); $fields = $fieldmodel->getFields(); $this->assignRef('fields',$fields); $this->assignRef('conf',$conf); $this->assignRef('userid',$user->id); $document->setTitle( JText::_('ADSMANAGER_PAGE_FAVORITES')); $field_values = $fieldmodel->getFieldValues(); $plugins = $fieldmodel->getPlugins(); $field = new JHTMLAdsmanagerField($conf,$field_values,'1',$plugins); $this->assignRef('field',$field); $general = new JHTMLAdsmanagerGeneral(0,$conf,$user); $this->assignRef('general',$general); parent::display($tpl); }
function display() { $app = JFactory::getApplication(); $user = JFactory::getUser(); $pathway = $app->getPathway(); $document = JFactory::getDocument(); $contentmodel = $this->getModel("content"); $catmodel = $this->getModel("category"); $configurationmodel = $this->getModel("configuration"); $uri = JFactory::getURI(); $this->requestURL = $uri->toString(); // Get the parameters of the active menu item $menus = $app->getMenu(); $menu = $menus->getActive(); $conf = $configurationmodel->getConfiguration(); if ($conf->show_rss == 0) { return; } $catid = JRequest::getInt('catid', 0); if ($catid != "0") { $category = $catmodel->getCategory($catid); $category->img = TTools::getCatImageUrl($catid, true); } else { $category->name = JText::_("ADSMANAGER_ALL_ADS"); $category->description = ""; $category->img = ""; } $filters = array(); $filters['publish'] = 1; if ($catid != 0) { $filters['category'] = $catid; } $listuser = JRequest::getInt('user', 0); if ($listuser != 0) { $filters['user'] = $listuser; $category->name = JText::_('ADSMANAGER_LIST_USER_TEXT') . " " . $user->username; } //$this->assignRef('list_description',$category->description); //$this->assignRef('contents',$contents); $document->setTitle(JText::_('ADSMANAGER_PAGE_TITLE') . JText::_($category->name)); $document->setDescription(""); //Add 1 $admin to avoid display top ads in the rss $contents = $contentmodel->getContents($filters, 0, 20, "a.date_created DESC ,a.id ", "DESC", 1); jimport('joomla.document.feed.feed'); require_once JPATH_ROOT . "/libraries/joomla/document/feed/feed.php"; foreach ($contents as $row) { // load individual item creator class $item = new JFeedItem(); $item->title = $row->ad_headline; $item->link = TRoute::_('index.php?option=com_adsmanager&view=details&catid=' . $row->catid . '&id=' . $row->id); $item->description = $row->ad_text; if (count($row->images) > 0) { $path = $thumbnail = JURI::base() . "images/com_adsmanager/ads/" . $row->images[0]->thumbnail; $image = '<img class="center" src="' . $path . '" alt="' . htmlspecialchars($row->ad_headline) . '"/>'; $item->description = $image . $item->description; } $item->date = $row->date_created; $item->category = $row->parent . " / " . $row->cat; $item->author = $author; // loads item info into rss array $document->addItem($item); } }
function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $pathway = $app->getPathway(); $document = JFactory::getDocument(); $contentmodel = $this->getModel("content"); $catmodel = $this->getModel("category"); $positionmodel = $this->getModel("position"); $columnmodel = $this->getModel("column"); $fieldmodel = $this->getModel("field"); $usermodel = $this->getModel("user"); $configurationmodel = $this->getModel("configuration"); $uri = JFactory::getURI(); $this->requestURL = $uri->toString(); // Get the parameters of the active menu item $menus = $app->getMenu(); $menu = $menus->getActive(); $conf = $configurationmodel->getConfiguration(); $catid = JRequest::getInt('catid', 0); $this->assignRef('catid', $catid); if ($catid != "0") { $category = $catmodel->getCategory($catid); $category->img = TTools::getCatImageUrl($catid, true); } else { $category = new stdClass(); $category->name = JText::_("ADSMANAGER_ALL_ADS"); $category->description = ""; $category->img = $this->get('baseurl') . 'components/com_adsmanager/images/default.gif'; } jimport('joomla.session.session'); $currentSession = JSession::getInstance('none', array()); $currentSession->set("search_fields", ""); $currentSession->set("searchfieldssql", " 1 "); $currentSession->set("searchfieldscatid", 0); $currentSession->set("tsearch", "", 'adsmanager'); $global_filter = JRequest::getInt('global_filter', 0); if ($global_filter == 1) { $searchfields = $fieldmodel->getFields(0); $globalfiltersql = $fieldmodel->getSearchFieldsSql($searchfields); $currentSession->set("sqlglobalfilter", $globalfiltersql); $currentSession->set("globalfilter_values", JRequest::get('request')); } $filters = array(); $filters['publish'] = 1; if ($catid != 0) { $filters['category'] = $catid; } if (isset($conf->publication_date) && $conf->publication_date == 1) { $filters['publication_date'] = 1; } $modeuser = 0; $listuser = JRequest::getInt('user', -1); if ($listuser == 0 && $user->id != 0) { $listuser = $user->id; } if ($listuser != -1) { $filters['user'] = $listuser; $user = $usermodel->getUser($listuser); if ($conf->display_fullname) { $category->name = JText::_('ADSMANAGER_LIST_USER_TEXT') . " " . $user->name; } else { $category->name = JText::_('ADSMANAGER_LIST_USER_TEXT') . " " . $user->username; } $this->assignRef('listuser', $listuser); $modeuser = 1; } $this->assignRef('modeuser', $modeuser); $session = JFactory::getSession(); $list_type = $session->get('list_type', '', 'adsmanager'); $list_value = $session->get('list_value', '', 'adsmanager'); if ($listuser != -1) { if ($list_type == 'user' && $list_value == $listuser) { $tsearch = JRequest::getVar('tsearch', $session->get('tsearch', '', 'adsmanager')); $session->set('tsearch', $tsearch, 'adsmanager'); } else { $session->set('list_type', 'user', 'adsmanager'); $session->set('list_value', $listuser, 'adsmanager'); $session->set('tsearch', '', 'adsmanager'); $tsearch = ''; } } else { if ($list_type == 'category' && $list_value == $catid) { $tsearch = JRequest::getVar('tsearch', $session->get('tsearch', '', 'adsmanager')); $session->set('tsearch', $tsearch, 'adsmanager'); } else { $session->set('list_type', 'category', 'adsmanager'); $session->set('list_value', $catid, 'adsmanager'); $session->set('tsearch', '', 'adsmanager'); $tsearch = ''; } } if ($tsearch != "") { $filters['search'] = $tsearch; } $this->assignRef('tsearch', $tsearch); if ($listuser == -1) { $subcats = $catmodel->getSubCats($catid, 'read'); $pathlist = $catmodel->getPathList($catid, 'read'); } else { $subcats = array(); $pathlist = array(); } $orderfields = $fieldmodel->getOrderFields($catid); $this->assignRef('orders', $orderfields); $this->assignRef('subcats', $subcats); $this->assignRef('pathlist', $pathlist); $limitstart = JRequest::getInt("limitstart", 0); $limit = $conf->ads_per_page; $fields = $fieldmodel->getFields(); $this->assignRef('fields', $fields); $order = $app->getUserStateFromRequest('com_adsmanager.front_content.order', 'order', 0, 'int'); $orderdir = $app->getUserStateFromRequest('com_adsmanager.front_content.orderdir', 'orderdir', 'DESC'); $orderdir = strtoupper($orderdir); if ($orderdir != "DESC" && $orderdir != "ASC") { $orderdir = "DESC"; } $filter_order = $contentmodel->getFilterOrder($order); $filter_order_dir = $orderdir; $this->assignRef('order', $order); $this->assignRef('orderdir', $orderdir); $this->assignRef('lists', $lists); $total = $contentmodel->getNbContents($filters); $contents = $contentmodel->getContents($filters, $limitstart, $limit, $filter_order, $filter_order_dir); jimport('joomla.html.pagination'); $pagination = new JPagination($total, $limitstart, $limit); $this->assignRef('pagination', $pagination); $this->assignRef('list_name', $category->name); $this->assignRef('list_img', $category->img); $this->assignRef('list_description', $category->description); $this->assignRef('contents', $contents); $mode = $app->getUserStateFromRequest('com_adsmanager.front_content.mode', 'mode', $conf->display_expand); if ($mode == 2) { $mode = 0; } $this->assignRef('mode', $mode); $columns = array(); $fcolumns = array(); $positions = array(); $fDisplay = array(); if ($mode == 0) { $columns = $columnmodel->getColumns($catid); $fcolumns = $fieldmodel->getFieldsbyColumns(); $this->assignRef('columns', $columns); $this->assignRef('fColumns', $fcolumns); } else { $positions = $positionmodel->getPositions(); $fDisplay = $fieldmodel->getFieldsbyPositions(); $this->assignRef('positions', $positions); $this->assignRef('fDisplay', $fDisplay); } $this->assignRef('conf', $conf); $this->assignRef('userid', $user->id); $this->assignRef('requestURL', $requestURL); $document->setTitle(JText::_('ADSMANAGER_PAGE_TITLE') . JText::_($category->name)); if ($catid != 0 && $conf->metadata_mode != 'nometadata') { $document->setMetaData("description", $category->metadata_description); $document->setMetaData("keywords", $category->metadata_keywords); } $field_values = $fieldmodel->getFieldValues(); $plugins = $fieldmodel->getPlugins(); $field = new JHTMLAdsmanagerField($conf, $field_values, $mode, $plugins); $this->assignRef('field', $field); //set breadcrumbs $nb = count($pathlist); for ($i = $nb - 1; $i >= 0; $i--) { $pathway->addItem($pathlist[$i]->text, $pathlist[$i]->link); } $general = new JHTMLAdsmanagerGeneral($catid, $conf, $user); $this->assignRef('general', $general); $searchfields = $fieldmodel->getSearchFields(); $cats = $catmodel->getCatTree(); $this->assignRef('searchfields', $searchfields); $this->assignRef('cats', $cats); $defaultvalues = array(); $this->assignRef('defaultvalues', $defaultvalues); $this->assignRef('catid', $catid); $text_search = ""; $this->assignRef('text_search', $text_search); parent::display($tpl); }
function delete() { $app = JFactory::getApplication(); $user = JFactory::getUser(); $id = JRequest::getInt('id', 0); if ($id == 0) { $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list')); } if ($user->id == 0) { TTools::redirectToLogin("index.php?option=com_adsmanager&task=delete&id=" . $id); return; } $this->addModelPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_adsmanager' . DS . 'models'); $configurationmodel = $this->getModel("configuration"); $fieldmodel = $this->getModel("field"); $content = JTable::getInstance('contents', 'AdsmanagerTable'); $content->load($id); if ($content == null || $content->userid != $user->id) { $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list')); } $conf = $configurationmodel->getConfiguration(); $plugins = $fieldmodel->getPlugins(); JPluginHelper::importPlugin('adsmanagercontent'); $dispatcher = JDispatcher::getInstance(); try { $results = $dispatcher->trigger('ADSonContentBeforeDelete', array($content, $conf)); } catch (Exception $e) { $errorMsg = $e->getMessage(); } $content->delete($id, $conf, $plugins); JPluginHelper::importPlugin('adsmanagercontent'); try { $results = $dispatcher->trigger('ADSonContentAfterDelete', array($content, $conf)); } catch (Exception $e) { $errorMsg = $e->getMessage(); } $cache = JFactory::getCache('com_adsmanager'); $cache->clean(); $app->redirect(TLink::getMyAdsLink(), JText::_('ADSMANAGER_CONTENT_REMOVED')); }
} else { $numAds = ''; } $link = TRoute::_("index.php?option=com_adsmanager&view=list&catid=" . $row->id); if ($row->level == 0) { ?> <div class="span<?php echo $classtype; ?> ads-span<?php echo $classtype; ?> "> <div class="span6 ads-span6"> <?php echo '<a href="' . $link . '" title="' . htmlspecialchars($row->name) . '"><img class="imgcat" src="' . TTools::getCatImageUrl($row->id) . '" alt="' . htmlspecialchars($row->name) . '" /></a>'; ?> </div> <div class="span6 ads-span6"> <h2 class="adsmanager_main_cat"><a href="<?php echo $link; ?> " ><?php echo htmlspecialchars($row->name) . $numAds; ?> </a></h2> <h3 class="adsmanager_sub_cat"> <?php $divopen = true; $firstsubcat = true; } else {
function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); $document = JFactory::getDocument(); $configurationmodel = $this->getModel("configuration"); $fieldmodel = $this->getModel("field"); $contentmodel = $this->getModel("content"); $catmodel = $this->getModel("category"); $usermodel = $this->getModel("user"); // Get the parameters of the active menu item $menus = $app->getMenu(); $menu = $menus->getActive(); $conf = $configurationmodel->getConfiguration(); if(!isset($conf->single_category_selection_type)) $conf->single_category_selection_type = 'normal'; $this->assignRef('conf',$conf); $fields = $fieldmodel->getFields(true,null,null,"fieldid","ASC",true,'write'); $this->assignRef('fields',$fields); $field_values = $fieldmodel->getFieldValues(); foreach($fields as $field) { if ($field->cbfieldvalues != "-1") { /*get CB value fields */ $cbfieldvalues = $fieldmodel->getCBFieldValues($field->cbfieldvalues); $field_values[$field->fieldid] = $cbfieldvalues; } } $this->assignRef('field_values',$field_values); $plugins = $fieldmodel->getPlugins(); $field = new JHTMLAdsmanagerField($conf,$field_values,"1",$plugins); $this->assignRef('field',$field); $errorMsg = JRequest::getString( 'errorMsg', "" ); $this->assignRef('errorMsg',$errorMsg); /* No need to user query, if errorMsg */ if ($errorMsg == "") { if ($conf->comprofiler == 0) { $profile = $usermodel->getProfile($user->id); } else if (COMMUNITY_BUILDER == 1) { $profile = $usermodel->getCBProfile($user->id); } else { $profile = new stdClass(); } $this->assignRef('default',$profile); } $contentid = JRequest::getInt( 'id', 0 ); // Update Ad ? if ($contentid > 0) { // edit ad $content = $contentmodel->getContent($contentid,false,1); //$content->ad_text = str_replace ('<br/>',"\r\n",$content->ad_text); if(!isset($this->isDuplicated)) $this->isDuplicated = 0; if ($user->id == 0) { $app->redirect( TRoute::_('index.php?option=com_adsmanager') ); } else if ($content->userid == $user->id) { if($this->isDuplicated == 1){ foreach($content->images as $image){ $src = 'images/com_adsmanager/ads/'.$image->image; $dest = 'images/com_adsmanager/ads/uploaded/'.$image->image; copy($src, $dest); } $content->id = 0; $isUpdateMode = 0; } else { $isUpdateMode = 1; } } else { $app->redirect(TLink::getMyAdsLink()); } } else { // insert $isUpdateMode = 0; } $this->assignRef('content',$content); if(isset($content->pendingdata->new_ad) && $content->pendingdata->new_ad == true) { $isUpdateMode = 0; } $this->assignRef('isUpdateMode',$isUpdateMode); $catid = JRequest::getInt('catid',0); // If Root cat is not allowed we must check that catid is correct $submit_allow = 1; if (($catid != 0)&&($conf->root_allowed == 0)) { $submit_allow = !$catmodel->isRootCategory($catid); } $this->assignRef('submit_allow',$submit_allow); if ($catid != 0) { if ($catmodel->isPublishedCategory($catid) == false) { $app->redirect( JRoute::_('index.php?option=com_adsmanager'),"Invalid Category selection","message"); return; } } if (($catid == 0)&&($isUpdateMode == 1)) { $catid = $content->cats[0]->catid; } $rootid = JRequest::getInt('rootid',0); $this->assignRef('rootid',$rootid); if ($catid != "0") { $category = $catmodel->getCategory($catid); $category->img = TTools::getCatImageUrl($catid,true); } else { $category = new stdClass(); $category->name = JText::_(""); $category->description = ""; $category->img = ""; } $this->assignRef('category',$category); $this->assignRef('catid',$catid); if (isset($content)) $extra = " - ".$content->ad_headline; else $extra = ""; $document->setTitle( JText::_('ADSMANAGER_PAGE_TITLE')." ".JText::_($category->name).$extra); $nbcats = $conf->nbcats; if (function_exists("getMaxCats")) { $nbcats = getMaxCats($conf->nbcats); } $this->assignRef('nbcats',$nbcats); if ($nbcats > 1) { $cats = $catmodel->getFlatTree(true, false, $nbContents, 'write',$rootid); } else { $rootid = JRequest::getInt('rootid',0); switch(@$conf->single_category_selection_type) { default: case 'normal': case 'color': case 'combobox': $cats = $catmodel->getFlatTree(true, false, $nbContents, 'write',$rootid); break; case 'cascade': $cats = $catmodel->getCategoriesPerLevel(true, false, $nbContents, 'write',$rootid); break; } } if(empty($cats)){ $app->redirect( JRoute::_('index.php?option=com_adsmanager&view=front&status=error'), JText::_('ADSMANAGER_NO_WRITE_RIGHT'),'message' ); } $this->assignRef('cats',$cats); if ($errorMsg != "") { //$post = (object) $_POST; $post = JRequest::get( 'post' ); $this->assignRef('default',$post); } if (($conf->submission_type == 2)&&($user->id == "0")) { $txt = JText::_('ADSMANAGER_WARNING_NEW_AD_NO_ACCOUNT'); $this->assignRef('warning_text',$txt); } switch($errorMsg) { case "bad_password": $txt = JText::_('ADSMANAGER_BAD_PASSWORD'); $this->assignRef('error_text',$txt); break; case "email_already_used": $txt = JText::_('ADSMANAGER_EMAIL_ALREADY_USED'); $this->assignRef('error_text',$txt); break; case "file_too_big": $txt = JText::_('ADSMANAGER_FILE_TOO_BIG'); $this->assignRef('error_text',$txt); break; default: if ($errorMsg != "") { $txt = $errorMsg; $this->assignRef('error_text',$txt); } } if (($conf->submission_type == 0)&&($user->id == 0)) { $account_creation = 1; } else $account_creation = 0; $this->assignRef('account_creation',$account_creation); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('adsmanagercontent'); $event = new stdClass(); $results = $dispatcher->trigger('ADSonContentAfterForm', array ($content)); $event->onContentAfterForm = trim(implode("\n", $results)); $this->assignRef('event',$event); if (PAIDSYSTEM) { if(isset($content->id)) { $db = JFactory::getDbo(); $db->setQuery( "SELECT * FROM #__paidsystem_ads WHERE id=".(int)$content->id ); $adext = $db->loadObject(); } else { $adext = new stdClass(); $adext->images = 0; } } else { $adext = new stdClass(); $adext->images = 0; } $this->assignRef('adext',$adext); parent::display($tpl); }
?> <?php } ?> </div> </div> <?php } $this->general->showGeneralLink(); if ($this->pagination->total == 0) { echo JText::_('ADSMANAGER_NOENTRIES'); } else { if (@$conf->display_map_list == 1) { echo TTools::loadModule('mod_adsmanager_adsmap', 'AdsMap'); } ?> <form name="adminForm" id="adminForm" method="post" action="<?php echo $this->requestURL; ?> " > <input type="hidden" id="mode" name="mode" value="<?php echo $this->mode; ?> "/> </form> <?php if ($this->mode == 0) { echo $this->loadTemplate('list'); } elseif ($this->mode == 1) {
function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $pathway = $app->getPathway(); $document = JFactory::getDocument(); if ($user->id == 0) { TTools::redirectToLogin("index.php?option=com_adsmanager&view=myads"); return; } $contentmodel =$this->getModel( "content" ); $catmodel =$this->getModel( "category" ); $positionmodel =$this->getModel( "position" ); $columnmodel =$this->getModel( "column" ); $fieldmodel =$this->getModel( "field" ); $usermodel =$this->getModel( "user" ); $configurationmodel =$this->getModel( "configuration" ); $uri = JFactory::getURI(); $this->requestURL = $uri->toString(); // Get the parameters of the active menu item $menus = $app->getMenu(); $menu = $menus->getActive(); $conf = $configurationmodel->getConfiguration(); jimport( 'joomla.session.session' ); $currentSession = JSession::getInstance('none',array()); $currentSession->set("search_fields",""); $currentSession->set("searchfieldscatid",0); $currentSession->set("searchfieldssql"," 1 "); $currentSession->set("tsearch",""); $filters = array(); $filters['user'] = $user->id; $tsearch = JRequest::getVar( 'tsearch', ''); if ($tsearch != "") { $filters['search'] = $tsearch; } $this->assignRef('tsearch',$tsearch); $username = $usermodel->getUser($user->id); if ($conf->display_fullname) { $name = JText::_('ADSMANAGER_LIST_USER_TEXT')." ".$user->name; } else { $name = JText::_('ADSMANAGER_LIST_USER_TEXT')." ".$user->username; } $orderfields = $fieldmodel->getOrderFields(0); $this->assignRef('orders',$orderfields); $limitstart = JRequest::getInt("limitstart",0); $limit = $app->getUserStateFromRequest('com_adsmanager.front_ads_per_page','limit',$conf->ads_per_page, 'int'); $order = $app->getUserStateFromRequest('com_adsmanager.front_content.order','order',0,'int'); $orderdir = $app->getUserStateFromRequest('com_adsmanager.front_content.orderid','orderdir','DESC'); $orderdir = strtoupper($orderdir); if (($orderdir != "DESC") && ($orderdir != "ASC")) { $orderdir = "DESC"; } $filter_order = $contentmodel->getFilterOrder($order); $filter_order_dir = $orderdir; $this->assignRef('order',$order); $this->assignRef('orderdir',$orderdir); $rootid = JRequest::getInt('rootid',0); $filters['rootid'] = $rootid; $total = $contentmodel->getNbContents($filters,1); $contents = $contentmodel->getContents($filters,$limitstart, $limit,$filter_order,$filter_order_dir,1); jimport('joomla.html.pagination'); $pagination = new JPagination($total, $limitstart, $limit); $this->assignRef('pagination',$pagination); $this->assignRef('list_name',$name); $this->assignRef('contents',$contents); $fields = $fieldmodel->getFields(); $this->assignRef('fields',$fields); $this->assignRef('conf',$conf); $this->assignRef('userid',$user->id); $document->setTitle( JText::_('ADSMANAGER_PAGE_MY_ADS')); $field_values = $fieldmodel->getFieldValues(); $plugins = $fieldmodel->getPlugins(); $field = new JHTMLAdsmanagerField($conf,$field_values,'1',$plugins); $this->assignRef('field',$field); $general = new JHTMLAdsmanagerGeneral(0,$conf,$user); $this->assignRef('general',$general); if (PAIDSYSTEM == 1) { require_once(JPATH_ROOT.'/administrator/components/com_paidsystem/models/top.php'); $topmodel = new PaidsystemModelTop(); $tops = $topmodel->getTops(); $topoption = null; foreach($tops as $t) { if ($t->duration == 1) { $topoption = $t; break; } } $this->assignRef('topoption',$topoption); } parent::display($tpl); }
<td class="hidden-phone"><?php echo $row->id; ?> </td> <td> <a href="<?php echo "index.php?option=com_adsmanager&c=categories&task=edit&id=" . $row->id; ?> "><?php echo $row->treename; ?> </a> </td> <td align="center"> <?php echo '<img src="' . TTools::getCatImageUrl($row->id, true) . '?time=' . time() . '"/>'; ?> </td> <td align='center'> <a href="<?php echo "index.php?option=com_adsmanager&c=contents&catid=" . $row->id; ?> "> <img src="<?php echo JURI::root(); ?> components/com_adsmanager/images/items.png"/> </a> </td> <?php if ($hasAjaxOrderingSupport === false) {
$num = 1; echo '</div>'; } if ($num == 1) { echo '<div class="row-fluid">'; } $num++; } if (isset($this->conf->display_nb_ads_per_categories) && $this->conf->display_nb_ads_per_categories) { $numAds = " (" . $row->num_ads . ")"; } else { $numAds = ''; } $link = TRoute::_("index.php?option=com_adsmanager&view=list&catid=" . $row->id); if ($row->level == 0) { $imgsrc = TTools::getCatImageUrl($row->id); ?> <div class="span<?php echo $classtype; ?> "> <div class="span12"> <div class="span6"> <?php echo '<a class="image" href="' . $link . '" title="' . htmlspecialchars($row->name) . '"><img class="imgcat" src="' . $imgsrc . '" alt="' . htmlspecialchars($row->name) . '" /></a>'; ?> </div> <div class="span6"> <h2 class="no-margin-top"><a href="<?php echo $link; ?>