function getAdHTML($addata, $adseen = 0, $adrotation = 0, $widget = '') { jimport('joomla.application.module.helper'); require JPATH_SITE . DS . "components" . DS . "com_socialads" . DS . "defines.php"; require JPATH_SITE . DS . "administrator" . DS . "components" . DS . "com_socialads" . DS . "config" . DS . "config.php"; global $mainframe; $mainframe = JFactory::getApplication(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $mod_sfx = ""; // $adRetriever = new adRetriever(); // $addata = $adRetriever->getAdDetails($ad_id); $module = JModuleHelper::getModule('socialads'); if ($mainframe->isSite() && $adseen == 1 && $addata != 0) { if (JVERSION >= '1.6.0') { $moduleParams = json_decode($module->params); $mod_sfx = $moduleParams->moduleclass_sfx; } else { $moduleParams = new JParameter($module->params); $mod_sfx = $moduleParams->get('moduleclass_sfx'); } } $zone_data = ''; if ($adseen == 1) { if ($addata == 0) { $buildadsession = JFactory::getSession(); $adses = $buildadsession->get('ad_data'); $addata = new stdClass(); $pluginlist = $buildadsession->get('addatapluginlist'); ///Extra code for zone pricing $addata->layout = $buildadsession->get('layout'); $addata->ad_image = str_replace(JUri::base(), '', $buildadsession->get('upimg')); if (!$buildadsession->get('adzone')) { $adzone = 1; } else { $adzone = $buildadsession->get('adzone'); } $addata->ad_title = $adses[2]['ad_title']; $addata->ad_body = $adses[3]['ad_body']; $query = "SELECT zone_type,max_title,max_des,img_width,img_height FROM #__ad_zone WHERE id =" . $adzone; $db->setQuery($query); $zone_data = $db->loadObjectList(); } else { //ad preview for the lightbox, showad , adsummary view $query = "SELECT * FROM #__ad_data WHERE ad_id =" . $addata; $db->setQuery($query); $addata = $db->loadObject(); } $addata->link = '#'; } if ($zone_data == '') { $query = "SELECT az.id AS zone_id,az.zone_type,az.max_title,az.max_des,az.img_width,az.img_height FROM #__ad_data as ad LEFT JOIN #__ad_zone as az ON ad.ad_zone=az.id WHERE ad_id =" . $addata->ad_id; $db->setQuery($query); $zone_data = $db->loadObjectList(); $adzone = $zone_data[0]->zone_id; //added in 2.7.5 stable } $tit = $addata->ad_title; $addata->ad_title = mb_substr($tit, 0, $zone_data[0]->max_title, 'UTF-8'); if ($addata->layout != 'layout6') { $bod = $addata->ad_body; $addata->ad_body = mb_substr($bod, 0, $zone_data[0]->max_des, 'UTF-8'); } $addata->ignore = ""; $upload_area = ''; $left_class = ' row-fluid '; if ($zone_data[0]->zone_type == 1 && $adseen == 0) { $left_class = " pull-left "; } //For the orientation of the Ad ie Horizontal or Vertical //$style = 'style="'.$float_style.'"'; $saad_entry_number = 0; if ($adrotation == 1) { $saad_entry_number = self::$ad_entry_number; ++self::$ad_entry_number; } @($html = '<div class = " ad_prev_main' . $mod_sfx . $left_class . ' " preview_for= "' . $addata->ad_id . '" ad_entry_number="' . $saad_entry_number . '" >'); if ($adseen == 0) { if ($this->_my->id == 1) { //$widget=''; if (!empty($_SERVER['HTTP_REFERER'])) { $parse = parse_url($_SERVER['HTTP_REFERER']); if ($widget != "") { $widget = '&widget=' . $parse['host'] . '|' . $widget; } } } else { $widget = '&widget=' . $widget; } $addata->link = JUri::root() . substr(JRoute::_("index.php?option=com_socialads&task=adredirector&adid=" . $addata->ad_id . "&caltype=1" . $widget), strlen(JUri::base(true)) + 1); if ($socialads_config['ignore'] != 0 && $this->_my->id != 0 && $this->_fromemail == 0) { if ($this->_my->id != 1) { $addata->ignore = "ignore_ads(this," . $addata->ad_id . "," . $socialads_config['feedback'] . ");"; } //$html .= '<img class="ad_ignore_button" src="'.JUri::Root().'components/com_socialads/images/fbcross.gif" onClick="ignore_ads(this,'.$addata->ad_id.','.$socialads_config["feedback"].');" />'; } } $plugin = 'plug_' . $addata->layout; $document->addStyleSheet(JUri::root() . 'components/com_socialads/css/helper.css'); $document->addScript(JUri::root() . 'components/com_socialads/js/helper.js'); $adRetriever = new adRetriever(); //START changed by manoj 2.7.5b2 //no passing zone id all time changed in 2.7.5 stable if (!$adseen) { $adHtmlTyped = $adRetriever->getAdHTMLByMedia($upload_area, $addata->ad_image, $addata->ad_body, $addata->link, $addata->layout, $track = 1, $adzone, $addata->ad_id); } else { if (!$addata) { $adHtmlTyped = $adRetriever->getAdHTMLByMedia($upload_area, $addata->ad_image, $addata->ad_body, $addata->link, $addata->layout, $track = 0, $adzone); } else { $adHtmlTyped = $adRetriever->getAdHTMLByMedia($upload_area, $addata->ad_image, $addata->ad_body, $addata->link, $addata->layout, $track = 0, $adzone); } } //END changed by manoj 2.7.5b2 if (JVERSION >= '1.6.0') { $layout = JPATH_SITE . DS . 'plugins' . DS . 'socialadslayout' . DS . $plugin . DS . $plugin . DS . 'layout.php'; } else { $layout = JPATH_SITE . DS . 'plugins' . DS . 'socialadslayout' . DS . $plugin . DS . 'layout.php'; } if (JFile::exists($layout)) { if (JVERSION >= '1.6.0') { $document->addStyleSheet(JUri::root() . 'plugins/socialadslayout/' . $plugin . '/' . $plugin . '/layout.css', 'text/css', '', array("id" => $addata->layout . 'css')); } else { $document->addStyleSheet(JUri::root() . 'plugins/socialadslayout/' . $plugin . '/layout.css', 'text/css', '', array("id" => $addata->layout . 'css')); } ob_start(); include $layout; $html .= ob_get_contents(); ob_end_clean(); } else { /*Ad title starts here...*/ $html .= '<!--div for preview ad-title--> <div class="ad_prev_first">'; if ($adseen == 0) { $html .= '<a class="ad_prev_anchor" href="' . $addata->link . '" target="_blank">' . $addata->ad_title . '</a>'; } else { $html .= $addata->ad_title; } $html .= '</div>'; /*Ad title ends here*/ /*Ad image starts here...*/ if ($addata->ad_image != '') { //check it image exists $html .= '<!--div for preview ad-image--> <div class="ad_prev_second">'; if ($adseen == 0) { $html .= '<a href="' . $addata->link . ' " target="_blank">'; } $html .= '<img class="ad_prev_img" src="' . JUri::Root() . $addata->ad_image . '" border="0" />'; if ($adseen == 0) { $html .= '</a>'; } $html .= '</div>'; } /*Ad image ends here*/ /*Ad description starts here...*/ $html .= '<!--div for preview ad-descrip--> <div class="ad_prev_third">' . $addata->ad_body . '</div>'; /*Ad description ends here*/ } $html .= '</div>'; return $html; }
function changelayout() { require JPATH_SITE . DS . "administrator" . DS . "components" . DS . "com_socialads" . DS . "config" . DS . "config.php"; $adseen = 2; $document = JFactory::getDocument(); $input = JFactory::getApplication()->input; //$post=$input->post; //$input->get $layout = $input->get('layout'); $addata = new stdClass(); $addata->ad_title = $input->get('title', '', 'STRING'); if ($addata->ad_title == '') { $addata->ad_title = JText::_("EXAMPLEAD"); } $addata->ad_body = $input->get('body', '', 'STRING'); if ($addata->ad_body == '') { $addata->ad_body = JText::_('SAMPLEAD'); } //START changed by manoj 2.7.5b2 $addata->link = '#'; $addata->ignore = ""; $upload_area = 'id="upload_area"'; $plugin = 'plug_' . $layout; $addata->ad_adtype_selected = $input->get('adtype'); $addata->adzone = $input->get('adzone'); /*added by manoj 2.7.5 stable*/ $addata->ad_image = ''; $adHtmlTyped = ''; if ($addata->ad_adtype_selected == 'text') { //$adHtmlTyped='<div class="preview-bodytext '.$layout.'_ad_prev_third">'; $adHtmlTyped .= $addata->ad_body; //$adHtmlTyped.='</div>'; } else { $addata->ad_image = $input->get('img', '', 'STRING'); $addata->ad_image = str_replace(JUri::base(), '', $addata->ad_image); if ($addata->ad_image == '') { $addata->ad_image = 'components/com_socialads/images/adimage.jpg'; } } require_once JPATH_SITE . DS . 'components' . DS . 'com_socialads' . DS . 'adshelper.php'; $adshelper = new adRetriever(); $adHtmlTyped = $adshelper->getAdHTMLByMedia($upload_area, $addata->ad_image, $addata->ad_body, $addata->link, $layout, $track = 0, $addata->adzone); //END changed by manoj 2.7.5b2 //$document->addStyleSheet(JUri::base().'components/com_socialads/css/helper.css'); //added by sagar if (JVERSION >= '1.6.0') { $layout = JPATH_SITE . DS . 'plugins' . DS . 'socialadslayout' . DS . $plugin . DS . $plugin . DS . 'layout.php'; $document->addStyleSheet(JUri::base() . 'plugins/socialadslayout/' . $plugin . '/' . $plugin . '/layout.css'); $css = JUri::base() . 'plugins/socialadslayout/' . $plugin . '/' . $plugin . '/layout.css'; } else { $layout = JPATH_SITE . DS . 'plugins' . DS . 'socialadslayout' . DS . $plugin . DS . 'layout.php'; $document->addStyleSheet(JUri::base() . 'plugins/socialadslayout/' . $plugin . '/layout.css'); $css = JUri::base() . 'plugins/socialadslayout/' . $plugin . '/layout.css'; } //added by sagar $document->addScript(JUri::base() . 'components/com_socialads/js/helper.js'); if (JFile::exists($layout)) { ob_start(); include $layout; $html = ob_get_contents(); ob_end_clean(); } else { $html = '<!--div for preview ad-image--> <div><a id="preview-title" class="preview-title-lnk" href="#">'; if ($addata->ad_title != '') { $html .= '' . $addata->ad_title; } else { $html .= '' . JText::_("EXAMPLEAD"); } $html .= '</a> </div> <!--div for preview ad-image--> <div id="upload_area" >'; if ($addata->ad_image != '') { $html .= '<img src="' . $addata->ad_image . '">'; } else { $html .= '<img src="' . JUri::Root() . 'components/com_socialads/images/adimage.jpg">'; } $html .= ' </div> <!--div for preview ad-bodytext--> <div id="preview-bodytext">'; if ($addata->ad_body != '') { $html .= '' . $addata->ad_body; } else { $html .= '' . JText::_('SAMPLEAD'); } $html .= '</div>'; } //@TODO //$js should be sent out only for video ads and flash ads $js = ' flowplayer("div.vid_ad_preview", { src:"' . JUri::root() . 'components' . DS . 'com_socialads' . DS . 'js' . DS . 'flowplayer-3.2.10.swf", wmode:"opaque" }, { canvas: { backgroundColor:"#000000", width:300, height:300 }, //default settings for the play button play: { opacity: 0.0, label: null, replayLabel: null, fadeSpeed: 500, rotateSpeed: 50 }, plugins:{ controls: { url:"' . JUri::root() . 'components' . DS . 'com_socialads' . DS . 'js' . DS . 'flowplayer.controls-3.2.10.swf", height:25, timeColor: "#980118", all: false, play: true, scrubber: true, volume: true, time: false, mute: true, progressColor: "#FF0000", bufferColor: "#669900", volumeColor: "#FF0000" } } }); '; $z = array("html" => $html, "css" => $css, "js" => $js); echo json_encode($z); jexit(); }