示例#1
0
	<?php 
    foreach ($items as $item) {
        $itemCanShow = $javconfig["systems"]->get("is_private", 0) == 0 || $item->is_private == 0 || $user->id == $item->user_id || $isSepecialUse;
        $listFiles = "";
        if (!$user->id && isset($_COOKIE[md5('jav-view-item') . $item->id])) {
            $item->votes = $_COOKIE[md5('jav-view-item') . $item->id];
        }
        $item->data = class_exists('JRegistry') ? new JRegistry($item->data) : new JParameter($item->data);
        $best_answer = $admin_response = array();
        $admin_responses = $this->getModel()->getAdmin_responses(" and r.item_id='{$item->id}'", 0, 2);
        $admin_avatar = '';
        if ($admin_responses) {
            foreach ($admin_responses as $row) {
                if ($row->type == 'admin_response') {
                    $admin_response = $row;
                    $admin_avatar = $helper->getAvatar($row->user_id);
                    break;
                }
            }
        }
        if ($this->type->has_answer) {
            foreach ($admin_responses as $row) {
                if ($row->type == 'best_answer') {
                    $best_answer = $row;
                    break;
                }
            }
        }
        if ($itemCanShow) {
            ?>
		<li class="jav-box-item <?php 
示例#2
0
 public function getItems()
 {
     global $javconfig;
     $mainframe = JFactory::getApplication();
     // Get the page/component configuration
     $params = $mainframe->getParams();
     // parameters
     $gl_cid = $params->def('item_id', '');
     $gl_uid = $params->def('user_id', '');
     $model = $this->getModel('items');
     $user = JFactory::getUser();
     $lists = $model->_getVars();
     //print_r($lists);exit;
     $type = $model->getVoiceType(JRequest::getInt('type', 1));
     if (JRequest::getVar('layout', 'default') == 'item') {
         $lists['limit'] = 1;
     }
     $where_more = '';
     $order = '';
     if (isset($lists['order']) && $lists['order'] != '') {
         if ($lists['order'] == 'create_date desc') {
             if ($javconfig["systems"]->get('is_set_time_new_voice', 1)) {
                 $lagNewVoice = $javconfig["systems"]->get('time_for_new_voice', 7200);
                 $where_more .= ' and (i.create_date +' . $lagNewVoice . ') >=' . time();
             } else {
                 $where_more .= ' and i.create_date>=' . $_SESSION['JAV_LAST_VISITED'];
             }
         }
         $order = $lists['order'] . ' ' . @$lists['order_Dir'];
     }
     if (JRequest::getInt('type')) {
         $where_more .= " and i.voice_types_id='" . JRequest::getInt('type') . "'";
     }
     if (JRequest::getInt('forums')) {
         $where_more .= " and i.forums_id='" . JRequest::getInt('forums') . "'";
     }
     if (JRequest::getVar('forums_id')) {
         if (JRequest::getVar('forums_id') == "no_forum") {
             return false;
         } else {
             $where_more .= " and i.forums_id in (" . JRequest::getVar('forums_id') . ")";
         }
     }
     if (JRequest::getInt('uid') && JRequest::getVar('view') == 'users') {
         $where_more .= ' and i.user_id=' . JRequest::getInt('uid');
     } elseif (intval($gl_uid)) {
         $where_more .= ' and i.user_id=' . (int) $gl_uid;
     }
     /* BEGIN: Show items are activing Only */
     $model_status = JAVBModel::getInstance('voicetypesstatus', 'javoiceModel');
     $list_status = $model_status->getListTreeStatus(0, false, 0);
     $model->getWhereWidget($where_more);
     $status = JRequest::getVar('status', NULL);
     if ($status) {
         if (is_numeric($status)) {
             $where_more .= " AND  i.voice_type_status_id='" . (int) $status . "' ";
         } else {
             $temps = explode(",", $status);
             $statusStr = array();
             foreach ($temps as $temp) {
                 $statusStr[] = "s.title LIKE '%{$temp}%'";
             }
             $where_more .= count($statusStr) ? ' AND ( ' . implode(' OR ', $statusStr) . ")" : '' . ")";
         }
     } else {
         if (JRequest::getString('key', '') == '') {
             $status_ids = array();
             foreach ($list_status as $k => $status) {
                 if ($status->parent_id != 0 && !$model_status->is_spam('', $status) || JRequest::getWord('layout') == 'item') {
                     $status_ids[] = $status->id;
                 }
             }
         } else {
             $status_ids = array();
             foreach ($list_status as $k => $status) {
                 if ($status->parent_id > 0 && (!$model_status->is_spam('', $status) || $model_status->is_closed('', $status)) || JRequest::getWord('layout') == 'item') {
                     $status_ids[] = $status->id;
                 }
             }
         }
         if (!$status_ids) {
             $status_ids = array(0);
         }
         $where_more .= " and ( i.voice_type_status_id in (" . implode(',', $status_ids) . ") or i.voice_type_status_id=0)";
     }
     /* END: Show items are activing Only */
     if ($cid = JRequest::getVar('cid', array(), '', 'array')) {
         JArrayHelper::toInteger($cid);
         if ($cid) {
             $cid = implode(',', $cid);
             $where_more .= " and i.id in ({$cid})";
         }
     } elseif (intval($gl_cid)) {
         $where_more .= " and i.id=" . (int) $gl_cid;
     }
     $where_more .= ' and i.published=1';
     if ($javconfig["systems"]->get("is_enable_tagging", 0) && JRequest::getVar("tagid", 0)) {
         $where_more .= " and tv.tagID='" . JRequest::getVar("tagid", 0) . "'";
     }
     $join = " LEFT JOIN #__jav_voice_type_status as s ON s.id=i.voice_type_status_id";
     $fields_join = ' s.title as status_title, s.class_css as status_class_css, s.allow_voting as status_allow_voting, s.parent_id as status_parent_id, s.published as status_publishded';
     if ($javconfig["systems"]->get("is_enable_tagging", 0) && JRequest::getVar("tagid", 0)) {
         $join .= " INNER JOIN #__jav_tags_voice as tv ON i.id=tv.voiceID";
         $fields_join .= ", tv.tagID";
     }
     if ($user->id) {
         $fields_join .= ', lg.votes';
         $join .= " LEFT JOIN #__jav_logs as lg ON (lg.item_id=i.id and lg.user_id='{$user->id}')";
     }
     if (JRequest::getVar("pagingtype") == "autoscroll") {
         //page
         $next_page = (int) JRequest::getVar("javpage");
         $lists['limitstart'] = $next_page * $lists['limit'];
     }
     $items = $model->getItems($where_more, trim($order), $lists['limitstart'], $lists['limit'], $fields_join, $join);
     $this->_totalc = $model->getCurrentTotal();
     if ($items) {
         $items = $model->parseItems_params($items, $type);
         //print_r($items);exit;
         foreach ($items as $k => $item) {
             //if($javconfig['plugin']->get('is_attach_image',1)){
             $path = JPATH_ROOT . DS . "images" . DS . "stories" . DS . "ja_voice" . DS . $item->id;
             $item->attachs[] = $model->formatFilesInDir($path, 'download', $item->user_id, $item->id);
             //}
             $helper = new JAVoiceHelpers();
             $item->avatar = $helper->getAvatar($item->user_id);
             if ($item->user_id) {
                 $userinfo = JFactory::getUser($item->user_id);
                 $item->username = $userinfo->username;
                 $item->userparams = $userinfo->getParameters();
                 $items[$k] = $item;
             }
         }
     }
     return $items;
 }