Code Duplication    Length = 38-44 lines in 2 locations

class/plugins/plugin.tag.php 1 location

@@ 28-71 (lines=44) @@
25
 *
26
 */
27
28
function lexikon_tag_iteminfo(&$items)
29
{
30
    if (empty($items) || !is_array($items)) {
31
        return false;
32
    }
33
34
    global $xoopsDB;
35
    $myts = MyTextSanitizer::getInstance();
36
37
    $items_id = array();
38
39
    foreach (array_keys($items) as $cat_id) {
40
        // Some handling here to build the link upon catid
41
        // If catid is not used, just skip it
42
        foreach (array_keys($items[$cat_id]) as $item_id) {
43
            // In article, the item_id is "art_id"
44
            $items_id[] = (int)$item_id;
45
        }
46
    }
47
48
    foreach (array_keys($items) as $cat_id) {
49
        foreach (array_keys($items[$cat_id]) as $item_id) {
50
            $sql = 'SELECT  l.entryID, l.categoryID, l.term AS ltitle, l.definition, l.uid, l.datesub, l.offline, c.name AS cname FROM '
51
                   . $xoopsDB->prefix('lxentries')
52
                   . ' l, '
53
                   . $xoopsDB->prefix('lxcategories')
54
                   . ' c WHERE l.entryID='
55
                   . $item_id
56
                   . ' AND l.categoryID=c.categoryID AND l.offline=0 ORDER BY l.datesub DESC';
57
            //$sql = "SELECT  l.entryID, l.categoryID, l.term as ltitle, l.definition, l.uid, l.datesub, l.offline,l.item_tag, c.name as cname FROM ".$xoopsDB->prefix('lxentries')." l, ".$xoopsDB->prefix('lxcategories')." c WHERE l.entryID=".$item_id." AND l.categoryID=c.categoryID AND l.offline=0 ORDER BY l.datesub DESC";
58
            $result                   = $xoopsDB->query($sql);
59
            $row                      = $xoopsDB->fetchArray($result);
60
            $items[$cat_id][$item_id] = array(
61
                'title'   => $row['ltitle'],
62
                'uid'     => $row['uid'],
63
                'link'    => "entry.php?entryID=$item_id",
64
                'time'    => $row['datesub'],
65
                //"tags"       => $row['item_tag'], // optional
66
                //"content"    => $myts->displayTarea( $row['definition'], 0 ),
67
                'content' => $row['definition']
68
            );
69
        }
70
    }
71
}
72
73

include/plugin.tag.php 1 location

@@ 29-66 (lines=38) @@
26
 *
27
 */
28
29
function lexikon_tag_iteminfo(&$items){
30
    if(empty($items) || !is_array($items)){
31
        return false;
32
    }
33
34
    global $xoopsDB;
35
    $myts = MyTextSanitizer::getInstance();
36
37
    $items_id = array();
38
39
    foreach(array_keys($items) as $cat_id){
40
        // Some handling here to build the link upon catid
41
            // If catid is not used, just skip it
42
        foreach(array_keys($items[$cat_id]) as $item_id){
43
            // In article, the item_id is "art_id"
44
            $items_id[] = intval($item_id);
45
        }
46
    }
47
48
    foreach(array_keys($items) as $cat_id){
49
        foreach(array_keys($items[$cat_id]) as $item_id){
50
            $sql = "SELECT  l.entryID, l.categoryID, l.term as ltitle, l.definition, l.uid, l.datesub, l.offline, c.name as cname FROM ".$xoopsDB->prefix('lxentries')." l, ".$xoopsDB->prefix('lxcategories')." c WHERE l.entryID=".$item_id." AND l.categoryID=c.categoryID AND l.offline=0 ORDER BY l.datesub DESC";
51
            //$sql = "SELECT  l.entryID, l.categoryID, l.term as ltitle, l.definition, l.uid, l.datesub, l.offline,l.item_tag, c.name as cname FROM ".$xoopsDB->prefix('lxentries')." l, ".$xoopsDB->prefix('lxcategories')." c WHERE l.entryID=".$item_id." AND l.categoryID=c.categoryID AND l.offline=0 ORDER BY l.datesub DESC";
52
            $result = $xoopsDB->query($sql);
53
            $row = $xoopsDB->fetchArray($result);
54
            $items[$cat_id][$item_id] = array(
55
                "title"        => $row['ltitle'],
56
                "uid"        => $row['uid'],
57
                "link"        => "entry.php?entryID=$item_id",
58
                "time"        => $row['datesub'],
59
                //"tags"       => $row['item_tag'], // optional
60
                //"content"    => $myts->displayTarea( $row['definition'], 0 ),
61
                "content"    => $row['definition'],
62
            );
63
        }
64
    }
65
66
}
67