Example #1
0
 /**
  * Plugin that returns the object list for DJ-Mediatools album
  * 
  * Each object must contain following properties (mandatory): title, description, image
  * Optional properties: link, target (_blank or _self), alt (alt attribute for image)
  * 
  * @param	object	The album params
  */
 public function onAlbumPrepare(&$source, &$params)
 {
     // Lets check the requirements
     $check = $this->onCheckRequirements($source);
     if (is_null($check) || is_string($check)) {
         return null;
     }
     $app = JFactory::getApplication();
     $default_image = $params->get('plg_classifieds_image');
     require_once JPATH_BASE . '/modules/mod_djclassifieds_items/helper.php';
     require_once JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_djclassifieds' . DS . 'lib' . DS . 'djtheme.php';
     require_once JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_djclassifieds' . DS . 'lib' . DS . 'djseo.php';
     $mparams = new JRegistry();
     foreach ($params->toArray() as $key => $value) {
         if (strpos($key, 'plg_classifieds_') !== FALSE) {
             $nkey = substr($key, 16);
             switch ($nkey) {
                 case 'catid':
                     $mparams->set('cat_id', $value);
                     break;
                 case 'follow_category':
                     $mparams->set('fallow_category', $value);
                     break;
                 case 'follow_region':
                     $mparams->set('fallow_region', $value);
                     break;
                 case 'only_promoted':
                     foreach ($value as $promo) {
                         $mparams->set('only_' . $promo, 1);
                     }
                     break;
                 default:
                     $mparams->set($nkey, $value);
                     break;
             }
         }
     }
     // override number of items
     $mparams->set('items_nr', $params->get('max_images'));
     // we need ads only with images
     if (empty($default_image)) {
         $mparams->set('only_with_img', 1);
     }
     //$this->debug($mparams);
     $items = modDjClassifiedsItems::getItems($mparams);
     $types = modDjClassifiedsItems::getTypes();
     $slides = array();
     if ($items) {
         foreach ($items as $i) {
             $slide = (object) array();
             if (!empty($i->img_path) && !empty($i->img_name) && !empty($i->img_ext)) {
                 // DJ-Classifieds 3.2+
                 $slide->image = $i->img_path . $i->img_name . '_thb.' . $i->img_ext;
             } else {
                 if (!empty($i->image_url)) {
                     // DJ-Classifieds version < 3.2
                     $images = explode(';', $i->image_url);
                     $slide->image = 'components/com_djclassifieds/images/' . $images[0];
                 } else {
                     if (!empty($default_image)) {
                         $slide->image = $default_image;
                     } else {
                         continue;
                     }
                 }
             }
             // we got image now take extra information
             $slide->extra = '';
             if ($mparams->get('show_date') == 1) {
                 $slide->extra .= '<div class="date">';
                 if (method_exists('DJClassifiedsTheme', 'formatDate')) {
                     $slide->extra .= DJClassifiedsTheme::formatDate(strtotime($i->date_start));
                 } else {
                     $slide->extra .= DJClassifiedsTheme::dateFormatFromTo(strtotime($i->date_start));
                 }
                 $slide->extra .= '</div>';
             }
             if ($mparams->get('show_cat') == 1) {
                 $slide->extra .= '<div class="category">';
                 if ($mparams->get('cat_link') == 1) {
                     $slide->extra .= '<a class="title_cat" href="' . JRoute::_(DJClassifiedsSEO::getCategoryRoute($i->cat_id . ':' . $i->c_alias)) . '">' . $i->c_name . '</a>';
                 } else {
                     $slide->extra .= $i->c_name;
                 }
                 $slide->extra .= '</div>';
             }
             if ($mparams->get('show_type') && $i->type_id > 0) {
                 if (isset($types[$i->type_id])) {
                     $slide->extra .= '<div class="type">';
                     $type = $types[$i->type_id];
                     if ($type->params->bt_class) {
                         $bt_class = ' ' . $type->params->bt_class;
                     } else {
                         $bt_class = '';
                     }
                     if ($type->params->bt_use_styles) {
                         if ($mparams->get('show_type') == 2) {
                             $style = 'style="display:inline-block;' . 'border:' . (int) $type->params->bt_border_size . 'px solid ' . $type->params->bt_border_color . ';' . 'background:' . $type->params->bt_bg . ';' . 'color:' . $type->params->bt_color . ';' . $type->params->bt_style . '"';
                             $slide->extra .= '<div class="type_button' . $bt_class . '" ' . $style . ' >' . $type->name . '</div>';
                         } else {
                             $slide->extra .= '<div class="type_label' . $bt_class . '" >' . $type->name . '</div>';
                         }
                     } else {
                         $slide->extra .= '<div class="type_label' . $bt_class . '" >' . $type->name . '</div>';
                     }
                     $slide->extra .= '</div>';
                 }
             }
             if ($mparams->get('show_region') == 1) {
                 $slide->extra .= '<div class="region">';
                 $slide->extra .= $i->r_name;
                 $slide->extra .= '</div>';
             }
             if ($mparams->get('show_price') == 1 && $i->price) {
                 $slide->extra .= '<div class="price">';
                 $slide->extra .= DJClassifiedsTheme::priceFormat($i->price, $i->currency);
                 $slide->extra .= '</div>';
             }
             // finish getting extra information
             $slide->title = $i->name;
             $slide->description = $i->intro_desc;
             if (empty($slide->description)) {
                 $slide->description = $i->description;
             }
             $slide->full_desc = $i->description;
             $slide->link = JRoute::_(DJClassifiedsSEO::getItemRoute($i->id . ':' . $i->alias, $i->cat_id . ':' . $i->c_alias));
             $slides[] = $slide;
         }
     }
     return $slides;
 }
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DJ Classifieds. If not, see <http://www.gnu.org/licenses/>.
* 
*/
defined('_JEXEC') or die('Restricted access');
if (!defined("DS")) {
    define('DS', DIRECTORY_SEPARATOR);
}
require_once dirname(__FILE__) . DS . 'helper.php';
require_once JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_djclassifieds' . DS . 'lib' . DS . 'djtheme.php';
require_once JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_djclassifieds' . DS . 'lib' . DS . 'djseo.php';
$params->set("cat_id", Jrequest::getVar("se_cats"));
$items = modDjClassifiedsItems::getItems($params);
$cfpar = JComponentHelper::getParams('com_djclassifieds');
$par_id = $params->get('mainid');
if ($params->get('show_type', '1')) {
    $types = modDjClassifiedsItems::getTypes();
}
if ($params->get('show_default_img', '0')) {
    $cat_images = modDjClassifiedsItems::getCatImages();
}
/*$menus	= JSite::getMenu();	
	$menu_item = $menus->getItems('link','index.php?option=com_djclassifieds&view=items&cid=0',1);
	$menu_item_blog = $menus->getItems('link','index.php?option=com_djclassifieds&view=items&layout=blog&cid=0',1);
			
	$itemid = ''; 
	if($menu_item){
		$itemid='&Itemid='.$menu_item->id;