Ejemplo n.º 1
0
/**
 * search publications (called as hook from search module, or directly with pager)
 *
 * @param $args['objectid'] could be the query ? (currently unused)
 * @param $args['extrainfo'] all other parameters ? (currently unused)
 * @return array output
 */
function publications_user_search($args)
{
    // pager stuff
    if (!xarVarFetch('startnum', 'int:0', $startnum, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // categories stuff
    if (!xarVarFetch('cids', 'array', $cids, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('andcids', 'str', $andcids, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('catid', 'str', $catid, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // single publication type when called via the pager
    if (!xarVarFetch('ptid', 'id', $ptid, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // multiple publication types when called via search hooks
    if (!xarVarFetch('ptids', 'array', $ptids, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // date stuff via forms
    if (!xarVarFetch('publications_startdate', 'str', $startdate, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('publications_enddate', 'str', $enddate, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // date stuff via URLs
    if (!xarVarFetch('start', 'int:0', $start, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('end', 'int:0', $end, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // search button was pressed
    if (!xarVarFetch('search', 'str', $search, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // select by article state (array or string)
    if (!xarVarFetch('state', 'isset', $state, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // yes, this is the query
    if (!xarVarFetch('q', 'str', $q, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('author', 'str', $author, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // filter by category
    if (!xarVarFetch('by', 'str', $by, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // can't use list enum here, because we don't know which sorts might be used
    if (!xarVarFetch('sort', 'regexp:/^[\\w,]*$/', $sort, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    // boolean AND/OR for words (no longer used)
    //if(!xarVarFetch('bool',     'str',   $bool,   NULL, XARVAR_NOT_REQUIRED)) {return;}
    // search in specific fields
    if (!xarVarFetch('publications_fields', 'isset', $fields, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('searchtype', 'isset', $searchtype, NULL, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (isset($args['objectid'])) {
        $ishooked = 1;
    } else {
        $ishooked = 0;
        if (empty($fields)) {
            // search in specific fields via URLs
            if (!xarVarFetch('fields', 'isset', $fields, NULL, XARVAR_NOT_REQUIRED)) {
                return;
            }
        }
    }
    // TODO: could we need this someday ?
    if (isset($args['extrainfo'])) {
        extract($args['extrainfo']);
    }
    // TODO: clean up this copy & paste stuff :-)
    // Default parameters
    if (!isset($startnum)) {
        $startnum = 1;
    }
    if (!isset($numitems)) {
        $numitems = 20;
    }
    if (!xarModAPILoad('publications', 'user')) {
        return;
    }
    // Get publication types
    $pubtypes = xarModAPIFunc('publications', 'user', 'get_pubtypes');
    if (xarSecurityCheck('AdminPublications', 0)) {
        $isadmin = true;
    } else {
        $isadmin = false;
    }
    // frontpage or approved state
    if (!$isadmin || !isset($state)) {
        $state = array(PUBLICATIONS_STATE_FRONTPAGE, PUBLICATIONS_STATE_APPROVED);
    } elseif (is_string($state)) {
        if (strpos($state, ' ')) {
            $state = explode(' ', $state);
        } elseif (strpos($state, '+')) {
            $state = explode('+', $state);
        } else {
            $state = array($state);
        }
    }
    $seenstate = array();
    foreach ($state as $that) {
        if (empty($that) || !is_numeric($that)) {
            continue;
        }
        $seenstate[$that] = 1;
    }
    $state = array_keys($seenstate);
    if (count($state) != 2 || !in_array(PUBLICATIONS_STATE_APPROVED, $state) || !in_array(PUBLICATIONS_STATE_FRONTPAGE, $state)) {
        $stateline = implode('+', $state);
    } else {
        $stateline = null;
    }
    if (!isset($sort)) {
        $sort = null;
    }
    // default publication type(s) to search in
    if (!empty($ptid) && isset($pubtypes[$ptid])) {
        $ptids = array($ptid);
        $settings = unserialize(xarModVars::get('publications', 'settings.' . $ptid));
        if (empty($settings['show_categories'])) {
            $show_categories = 0;
        } else {
            $show_categories = 1;
        }
    } elseif (!empty($ptids) && count($ptids) > 0) {
        foreach ($ptids as $curptid) {
            // default view doesn't apply here ?!
        }
        $show_categories = 1;
    } elseif (!isset($ptids)) {
        //    $ptids = array(xarModVars::get('publications','defaultpubtype'));
        $ptids = array();
        foreach ($pubtypes as $pubid => $pubtype) {
            $ptids[] = $pubid;
        }
        $show_categories = 1;
    } else {
        // TODO: rethink this when we're dealing with multi-pubtype categories
        $show_categories = 0;
    }
    // turn $catid into $cids array (and set $andcids flag)
    if (!empty($catid)) {
        if (strpos($catid, ' ')) {
            $cids = explode(' ', $catid);
            $andcids = true;
        } elseif (strpos($catid, '+')) {
            $cids = explode('+', $catid);
            $andcids = true;
        } else {
            $cids = explode('-', $catid);
            $andcids = false;
        }
    }
    $seencid = array();
    $catid = null;
    if (isset($cids) && is_array($cids)) {
        foreach ($cids as $cid) {
            if (empty($cid) || !preg_match('/^_?[0-9]+$/', $cid)) {
                continue;
            }
            $seencid[$cid] = 1;
        }
        $cids = array_keys($seencid);
        if ($andcids) {
            $catid = join('+', $cids);
        } else {
            $catid = join('-', $cids);
        }
    }
    $seenptid = array();
    if (isset($ptids) && is_array($ptids)) {
        foreach ($ptids as $curptid) {
            if (empty($curptid) || !isset($pubtypes[$curptid])) {
                continue;
            }
            $seenptid[$curptid] = 1;
        }
        $ptids = array_keys($seenptid);
    }
    /* Ensure whitespace alone not passed to api -causes errors */
    if (isset($q) && trim($q) === '') {
        $q = null;
    }
    // Find the id of the author we're looking for
    if (!empty($author)) {
        // Load API
        if (!xarModAPILoad('roles', 'user')) {
            return;
        }
        $user = xarModAPIFunc('roles', 'user', 'get', array('name' => $author));
        if (!empty($user['uid'])) {
            $owner = $user['uid'];
        } else {
            $owner = null;
            $author = null;
        }
    } else {
        $owner = null;
        $author = null;
    }
    if (isset($start) && is_numeric($start)) {
        $startdate = xarLocaleFormatDate("%Y-%m-%d %H:%M:%S", $start);
    }
    if (isset($end) && is_numeric($end)) {
        $enddate = xarLocaleFormatDate("%Y-%m-%d %H:%M:%S", $end);
    }
    if (empty($fields)) {
        $fieldlist = array('title', 'description', 'summary', 'body1');
    } else {
        $fieldlist = array_keys($fields);
        // don't pass fields via URLs if we stick to the default list
        if (count($fields) == 3 && isset($fields['title']) && isset($fields['description']) && isset($fields['summary']) && isset($fields['body1'])) {
            $fields = null;
        }
    }
    // Set default searchtype to 'fulltext' if necessary
    $fulltext = xarModVars::get('publications', 'fulltextsearch');
    if (!isset($searchtype) && !empty($fulltext)) {
        $searchtype = 'fulltext';
    }
    // FIXME: fulltext only supports searching in all configured text fields !
    if (empty($fields) && !empty($fulltext) && !empty($searchtype) && $searchtype == 'fulltext') {
        $fieldlist = explode(',', $fulltext);
    }
    $data = array();
    $data['results'] = array();
    $data['state'] = '';
    $data['ishooked'] = $ishooked;
    // TODO: MichelV: $ishooked is never empty, but either 0 or 1
    if (empty($ishooked)) {
        $data['q'] = isset($q) ? xarVarPrepForDisplay($q) : null;
        $data['author'] = isset($author) ? xarVarPrepForDisplay($author) : null;
        $data['searchtype'] = $searchtype;
    }
    if ($isadmin) {
        $states = xarModAPIFunc('publications', 'user', 'getstates');
        $data['statelist'] = array();
        foreach ($states as $id => $name) {
            $data['statelist'][] = array('id' => $id, 'name' => $name, 'checked' => in_array($id, $state));
        }
    }
    // TODO: show field labels when we're dealing with only 1 pubtype
    $data['fieldlist'] = array(array('id' => 'title', 'name' => xarML('title'), 'checked' => in_array('title', $fieldlist)), array('id' => 'description', 'name' => xarML('description'), 'checked' => in_array('description', $fieldlist)), array('id' => 'summary', 'name' => xarML('summary'), 'checked' => in_array('summary', $fieldlist)), array('id' => 'body1', 'name' => xarML('body1'), 'checked' => in_array('body1', $fieldlist)), array('id' => 'notes', 'name' => xarML('notes'), 'checked' => in_array('notes', $fieldlist)));
    $data['publications'] = array();
    foreach ($pubtypes as $pubid => $pubtype) {
        if (!empty($seenptid[$pubid])) {
            $checked = ' checked="checked"';
        } else {
            $checked = '';
        }
        $data['publications'][] = array('id' => $pubid, 'description' => xarVarPrepForDisplay($pubtype['description']), 'checked' => $checked);
    }
    $data['categories'] = array();
    if (!empty($by) && $by == 'cat') {
        $catarray = array();
        foreach ($ptids as $curptid) {
            // get root categories for this publication type
            $catlinks = xarModAPIFunc('categories', 'user', 'getallcatbases', array('module' => 'publications', 'itemtype' => $curptid));
            foreach ($catlinks as $cat) {
                $catarray[$cat['category_id']] = $cat['name'];
            }
        }
        foreach ($catarray as $cid => $title) {
            $select = xarModAPIFunc('categories', 'visual', 'makeselect', array('cid' => $cid, 'return_itself' => true, 'select_itself' => true, 'values' => &$seencid, 'multiple' => 1));
            $data['categories'][] = array('cattitle' => $title, 'catselect' => $select);
        }
        $data['searchurl'] = xarModURL('search', 'user', 'main');
    } else {
        $data['searchurl'] = xarModURL('search', 'user', 'main', array('by' => 'cat'));
    }
    $now = time();
    if (empty($startdate)) {
        $startdate = null;
        $data['startdate'] = 'N/A';
    } else {
        if (!preg_match('/[a-zA-Z]+/', $startdate)) {
            $startdate .= ' GMT';
        }
        $startdate = strtotime($startdate);
        // adjust for the user's timezone offset
        $startdate -= xarMLS_userOffset() * 3600;
        if ($startdate > $now && !$isadmin) {
            $startdate = $now;
        }
        $data['startdate'] = $startdate;
    }
    if (empty($enddate)) {
        $enddate = $now;
        $data['enddate'] = 'N/A';
    } else {
        if (!preg_match('/[a-zA-Z]+/', $enddate)) {
            $enddate .= ' GMT';
        }
        $enddate = strtotime($enddate);
        // adjust for the user's timezone offset
        $enddate -= xarMLS_userOffset() * 3600;
        if ($enddate > $now && !$isadmin) {
            $enddate = $now;
        }
        $data['enddate'] = $enddate;
    }
    if (!empty($q) || !empty($author) && isset($owner) || !empty($search) || !empty($ptid) || !empty($startdate) || $enddate != $now || !empty($catid)) {
        $getfields = array('id', 'title', 'start_date', 'pubtype_id', 'cids');
        // Return the relevance when using MySQL full-text search
        //if (!empty($search) && !empty($searchtype) && substr($searchtype,0,8) == 'fulltext') {
        //    $getfields[] = 'relevance';
        //}
        $count = 0;
        // TODO: allow combination of searches ?
        foreach ($ptids as $curptid) {
            $publications = xarModAPIFunc('publications', 'user', 'getall', array('startnum' => $startnum, 'cids' => $cids, 'andcids' => $andcids, 'ptid' => $curptid, 'owner' => $owner, 'sort' => $sort, 'numitems' => $numitems, 'state' => $state, 'start_date' => $startdate, 'end_date' => $enddate, 'searchfields' => $fieldlist, 'searchtype' => $searchtype, 'search' => $q, 'fields' => $getfields));
            // TODO: re-use article output code from elsewhere (view / archive / admin)
            if (!empty($publications) && count($publications) > 0) {
                // retrieve the categories for each article
                $catinfo = array();
                if ($show_categories) {
                    $cidlist = array();
                    foreach ($publications as $article) {
                        if (!empty($article['cids']) && count($article['cids']) > 0) {
                            foreach ($article['cids'] as $cid) {
                                $cidlist[$cid] = 1;
                            }
                        }
                    }
                    if (count($cidlist) > 0) {
                        $catinfo = xarModAPIFunc('categories', 'user', 'getcatinfo', array('cids' => array_keys($cidlist)));
                        // get root categories for this publication type
                        $catroots = xarModAPIFunc('publications', 'user', 'getrootcats', array('ptid' => $curptid));
                        $catroots = xarModAPIFunc('categories', 'user', 'getallcatbases', array('module' => 'publications', 'itemtype' => $curptid));
                    }
                    foreach ($catinfo as $cid => $info) {
                        $catinfo[$cid]['name'] = xarVarPrepForDisplay($info['name']);
                        $catinfo[$cid]['link'] = xarModURL('publications', 'user', 'view', array('ptid' => $curptid, 'catid' => $catid && $andcids ? $catid . '+' . $cid : $cid));
                        // only needed when sorting by root category id
                        $catinfo[$cid]['root'] = 0;
                        // means not found under a root category
                        // only needed when sorting by root category order
                        $catinfo[$cid]['order'] = 0;
                        // means not found under a root category
                        $rootidx = 1;
                        foreach ($catroots as $rootcat) {
                            // see if we're a child category of this rootcat (cfr. Celko model)
                            if ($info['left'] >= $rootcat['left_id'] && $info['left'] < $rootcat['right_id']) {
                                // only needed when sorting by root category id
                                $catinfo[$cid]['root'] = $rootcat['category_id'];
                                // only needed when sorting by root category order
                                $catinfo[$cid]['order'] = $rootidx;
                                break;
                            }
                            $rootidx++;
                        }
                    }
                }
                // needed for sort function below
                $GLOBALS['artsearchcatinfo'] = $catinfo;
                $items = array();
                foreach ($publications as $article) {
                    $count++;
                    $curptid = $article['pubtype_id'];
                    $link = xarModURL('publications', 'user', 'display', array('ptid' => $article['pubtype_id'], 'itemid' => $article['id']));
                    // publication date of article (if needed)
                    if (!empty($pubtypes[$curptid]['config']['startdate']['label']) && !empty($article['startdate'])) {
                        $date = xarLocaleFormatDate('%a, %d %B %Y %H:%M:%S %Z', $article['startdate']);
                        $startdate = $article['startdate'];
                    } else {
                        $date = '';
                        $startdate = 0;
                    }
                    if (empty($article['title'])) {
                        $article['title'] = xarML('(none)');
                    }
                    // categories this article belongs to
                    $categories = array();
                    if ($show_categories && !empty($article['cids']) && is_array($article['cids']) && count($article['cids']) > 0) {
                        $cidlist = $article['cids'];
                        // order cids by root category order
                        usort($cidlist, 'publications_search_sortbyorder');
                        // order cids by root category id
                        //usort($cidlist,'publications_search_sortbyroot');
                        // order cids by position in Celko tree
                        //usort($cidlist,'publications_search_sortbyleft');
                        $join = '';
                        foreach ($cidlist as $cid) {
                            $item = array();
                            if (!isset($catinfo[$cid])) {
                                // oops
                                continue;
                            }
                            $categories[] = array('cname' => $catinfo[$cid]['name'], 'clink' => $catinfo[$cid]['link'], 'cjoin' => $join);
                            if (empty($join)) {
                                $join = ' | ';
                            }
                        }
                    }
                    $items[] = array('title' => xarVarPrepHTMLDisplay($article['title']), 'link' => $link, 'date' => $date, 'startdate' => $startdate, 'relevance' => isset($article['relevance']) ? $article['relevance'] : null, 'categories' => $categories);
                }
                unset($publications);
                // Pager
                // TODO: make count depend on locale in the future
                sys::import('modules.base.class.pager');
                $pager = xarTplPager::getPager($startnum, xarModAPIFunc('publications', 'user', 'countitems', array('cids' => $cids, 'andcids' => $andcids, 'ptid' => $curptid, 'owner' => $owner, 'state' => $state, 'startdate' => $startdate, 'enddate' => $enddate, 'searchfields' => $fieldlist, 'searchtype' => $searchtype, 'search' => $q)), xarModURL('publications', 'user', 'search', array('ptid' => $curptid, 'catid' => $catid, 'q' => isset($q) ? $q : null, 'author' => isset($author) ? $author : null, 'start' => $startdate, 'end' => $enddate != $now ? $enddate : null, 'state' => $stateline, 'sort' => $sort, 'fields' => $fields, 'searchtype' => !empty($searchtype) ? $searchtype : null, 'startnum' => '%%')), $numitems);
                if (strlen($pager) > 5) {
                    if (!isset($sort) || $sort == 'date') {
                        $othersort = 'title';
                    } else {
                        $othersort = null;
                    }
                    $sortlink = xarModURL('publications', 'user', 'search', array('ptid' => $curptid, 'catid' => $catid, 'q' => isset($q) ? $q : null, 'author' => isset($author) ? $author : null, 'start' => $startdate, 'end' => $enddate != $now ? $enddate : null, 'state' => $stateline, 'fields' => $fields, 'searchtype' => !empty($searchtype) ? $searchtype : null, 'sort' => $othersort));
                    if (!isset($othersort)) {
                        $othersort = 'date';
                    }
                    $pager .= '&#160;&#160;<a href="' . $sortlink . '">' . xarML('sort by') . ' ' . xarML($othersort) . '</a>';
                }
                $data['results'][] = array('description' => xarVarPrepForDisplay($pubtypes[$curptid]['description']), 'items' => $items, 'pager' => $pager);
            }
        }
        unset($catinfo);
        unset($items);
        unset($GLOBALS['artsearchcatinfo']);
        if ($count > 0) {
            // bail out, we have what we needed
            return xarTplModule('publications', 'user', 'search', $data);
        }
        $data['state'] = xarML('No pages found matching this search');
    }
    return xarTplModule('publications', 'user', 'search', $data);
}
Ejemplo n.º 2
0
 public function display(array $data = array())
 {
     $data = $this->getContent();
     // see if we're currently displaying an article
     if (xarVarIsCached('Blocks.publications', 'id')) {
         $curid = xarVarGetCached('Blocks.publications', 'id');
     } else {
         $curid = -1;
     }
     if (!empty($data['dynamictitle'])) {
         if ($data['toptype'] == 'rating') {
             $data['title'] = xarML('Top Rated');
         } elseif ($data['toptype'] == 'hits') {
             $data['title'] = xarML('Top');
         } else {
             $data['title'] = xarML('Latest');
         }
     }
     if (!empty($data['nocatlimit'])) {
         // don't limit by category
         $cid = 0;
         $cidsarray = array();
     } else {
         if (!empty($data['catfilter'])) {
             // use admin defined category
             $cidsarray = array($data['catfilter']);
             $cid = $data['catfilter'];
         } else {
             // use the current category
             // Jonn: this currently only works with one category at a time
             // it could be reworked to support multiple cids
             if (xarVarIsCached('Blocks.publications', 'cids')) {
                 $curcids = xarVarGetCached('Blocks.publications', 'cids');
                 if (!empty($curcids)) {
                     if ($curid == -1) {
                         //$cid = $curcids[0]['name'];
                         $cid = $curcids[0];
                         $cidsarray = array($curcids[0]);
                     } else {
                         $cid = $curcids[0];
                         $cidsarray = array($curcids[0]);
                     }
                 } else {
                     $cid = 0;
                     $cidsarray = array();
                 }
             } else {
                 // pull from all categories
                 $cid = 0;
                 $cidsarray = array();
             }
         }
         //echo $includechildren;
         if (!empty($data['includechildren']) && !empty($cidsarray[0]) && !strstr($cidsarray[0], '_')) {
             $cidsarray[0] = '_' . $cidsarray[0];
         }
         if (!empty($cid)) {
             // if we're viewing all items below a certain category, i.e. catid = _NN
             $cid = str_replace('_', '', $cid);
             $thiscategory = xarModAPIFunc('categories', 'user', 'getcat', array('cid' => $cid, 'return_itself' => 'return_itself'));
         }
         if (!empty($cidsarray) && isset($thiscategory[0]['name']) && !empty($data['dynamictitle'])) {
             $data['title'] .= ' ' . $thiscategory[0]['name'];
         }
     }
     // Get publication types
     // MarieA - moved to always get pubtypes.
     $publication_types = xarModAPIFunc('publications', 'user', 'get_pubtypes');
     if (!empty($data['nopublimit'])) {
         //don't limit by publication type
         $ptid = 0;
         if (!empty($data['dynamictitle'])) {
             $data['title'] .= ' ' . xarML('Content');
         }
     } else {
         // MikeC: Check to see if admin has specified that only a specific
         // Publication Type should be displayed.  If not, then default to original TopItems configuration.
         if ($data['pubtype_id'] == 0) {
             if (xarVarIsCached('Blocks.publications', 'ptid')) {
                 $ptid = xarVarGetCached('Blocks.publications', 'ptid');
             }
             if (empty($ptid)) {
                 // default publication type
                 $ptid = xarModVars::get('publications', 'defaultpubtype');
             }
         } else {
             // MikeC: Admin Specified a publication type, use it.
             $ptid = $data['pubtype_id'];
         }
         if (!empty($data['dynamictitle'])) {
             if (!empty($ptid) && isset($publication_types[$ptid]['description'])) {
                 $data['title'] .= ' ' . xarVarPrepForDisplay($publication_types[$ptid]['description']);
             } else {
                 $data['title'] .= ' ' . xarML('Content');
             }
         }
     }
     // frontpage or approved state
     if (empty($data['pubstate'])) {
         $statearray = array(2, 3);
     } elseif (!is_array($data['pubstate'])) {
         $statearray = preg_split('/,/', $data['pubstate']);
     } else {
         $statearray = $data['pubstate'];
     }
     // get cids for security check in getall
     $fields = array('id', 'title', 'pubtype_id', 'cids');
     if ($data['toptype'] == 'rating' && xarModIsHooked('ratings', 'publications', $ptid)) {
         array_push($fields, 'rating');
         $sort = 'rating';
     } elseif ($data['toptype'] == 'hits' && xarModIsHooked('hitcount', 'publications', $ptid)) {
         array_push($fields, 'counter');
         $sort = 'hits';
     } else {
         array_push($fields, 'create_date');
         $sort = 'date';
     }
     if (!empty($data['showsummary'])) {
         array_push($fields, 'summary');
     }
     if (!empty($data['showdynamic']) && xarModIsHooked('dynamicdata', 'publications', $ptid)) {
         array_push($fields, 'dynamicdata');
     }
     $publications = xarModAPIFunc('publications', 'user', 'getall', array('ptid' => $ptid, 'cids' => $cidsarray, 'andcids' => 'false', 'state' => $statearray, 'create_date' => time(), 'fields' => $fields, 'sort' => $sort, 'numitems' => $data['numitems']));
     if (!isset($publications) || !is_array($publications) || count($publications) == 0) {
         return;
     }
     $items = array();
     foreach ($publications as $article) {
         $article['title'] = xarVarPrepHTMLDisplay($article['title']);
         if ($article['id'] != $curid) {
             // Use the filtered category if set, and not including children
             $article['link'] = xarModURL('publications', 'user', 'display', array('itemid' => $article['id'], 'catid' => !empty($data['linkcat']) && !empty($data['catfilter']) ? $data['catfilter'] : NULL));
         } else {
             $article['link'] = '';
         }
         if (!empty($data['showvalue'])) {
             if ($data['toptype'] == 'rating') {
                 if (!empty($article['rating'])) {
                     $article['value'] = intval($article['rating']);
                 } else {
                     $article['value'] = 0;
                 }
             } elseif ($data['toptype'] == 'hits') {
                 if (!empty($article['counter'])) {
                     $article['value'] = $article['counter'];
                 } else {
                     $article['value'] = 0;
                 }
             } else {
                 // TODO: make user-dependent
                 if (!empty($article['create_date'])) {
                     //$article['value'] = strftime("%Y-%m-%d", $article['create_date']);
                     $article['value'] = xarLocaleGetFormattedDate('short', $article['create_date']);
                 } else {
                     $article['value'] = 0;
                 }
             }
         } else {
             $article['value'] = 0;
         }
         // MikeC: Bring the summary field back as $desc
         if (!empty($data['showsummary'])) {
             $article['summary'] = xarVarPrepHTMLDisplay($article['summary']);
             $article['transform'] = array('summary', 'title');
             $article = xarModCallHooks('item', 'transform', $article['id'], $article, 'publications');
         } else {
             $article['summary'] = '';
         }
         // MarieA: Bring the pubtype description back as $descr
         if (!empty($data['nopublimit'])) {
             $article['pubtypedescr'] = $publication_types[$article['pubtype_id']]['description'];
             //jojodee: while we are here bring the pubtype name back as well
             $article['pubtypename'] = $publication_types[$article['pubtype_id']]['name'];
         }
         // this will also pass any dynamic data fields (if any)
         $items[] = $article;
     }
     $data['items'] = $items;
     if (!empty($data['dynamictitle'])) {
         $this->setTitle($data['title']);
     }
     return $data;
 }