Exemplo n.º 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;
 }
Exemplo n.º 2
0
         }
     }
 }
 if ($params->get('show_title', '1') == 1) {
     $title_c = $params->get('char_title_nr', 0);
     if ($title_c > 0 && strlen($i->name) > $title_c) {
         $i->name = mb_substr($i->name, 0, $title_c, 'utf-8') . ' ...';
     }
     echo '<a class="title" href="' . JRoute::_(DJClassifiedsSEO::getItemRoute($i->id . ':' . $i->alias, $i->cat_id . ':' . $i->c_alias)) . '">' . $i->name . '</a>';
 }
 if ($params->get('show_date') == 1 || $params->get('show_cat') == 1 || $params->get('show_price') == 1 || $params->get('show_type', '1')) {
     echo '<div class="date_cat">';
     if ($params->get('show_date') == 1) {
         echo '<span class="date">';
         if ($cfpar->get('date_format_type_modules', 0)) {
             echo DJClassifiedsTheme::dateFormatFromTo(strtotime($i->date_start));
         } else {
             echo date($cfpar->get('date_format', 'Y-m-d H:i:s'), strtotime($i->date_start));
         }
         echo '</span>';
     }
     if ($params->get('show_cat') == 1) {
         echo '<span class="category">';
         if ($params->get('cat_link') == 1) {
             echo '<a class="title_cat" href="' . JRoute::_(DJClassifiedsSEO::getCategoryRoute($i->cat_id . ':' . $i->c_alias)) . '">' . $i->c_name . '</a>';
         } else {
             echo $i->c_name;
         }
         echo '</span>';
     }
     if ($params->get('show_type', '1') && $i->type_id > 0) {
Exemplo n.º 3
0
 public static function formatDate($from, $to = null)
 {
     $par = JComponentHelper::getParams('com_djclassifieds');
     if ($par->get('date_format_type', 0)) {
         return DJClassifiedsTheme::dateFormatFromTo($from, $to);
     } else {
         if ($par->get('date_persian', 0)) {
             return mds_date($par->get('date_format', 'Y-m-d H:i:s'), $from, 1);
         } else {
             return date($par->get('date_format', 'Y-m-d H:i:s'), $from);
         }
     }
 }
Exemplo n.º 4
0
 public static function formatDate($from, $to = null, $date_format = 0)
 {
     $par = JComponentHelper::getParams('com_djclassifieds');
     if ($from == '2145913200') {
         return JText::_('COM_DJCLASSIFIEDS_NEVER_EXPIRE');
     } else {
         if ($date_format) {
             return DJClassifiedsTheme::dateFormatFromTo($from, $to);
         } else {
             if ($par->get('date_persian', 0)) {
                 return mds_date($par->get('date_format', 'Y-m-d H:i:s'), $from, 1);
             } else {
                 return date($par->get('date_format', 'Y-m-d H:i:s'), $from);
             }
         }
     }
 }