[Cinemaru-svn] cinemaru-svn [195] 関連動画情報を得るプラグイン

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 3月 24日 (火) 13:15:49 JST


Revision: 195
          http://svn.sourceforge.jp/view?root=cinemaru&view=rev&rev=195
Author:   tokita
Date:     2009-03-24 13:15:49 +0900 (Tue, 24 Mar 2009)

Log Message:
-----------
関連動画情報を得るプラグイン

Added Paths:
-----------
    trunk/html/class/smarty/plugins/function.cinemaru_related_movie_get.php

Added: trunk/html/class/smarty/plugins/function.cinemaru_related_movie_get.php
===================================================================
--- trunk/html/class/smarty/plugins/function.cinemaru_related_movie_get.php	                        (rev 0)
+++ trunk/html/class/smarty/plugins/function.cinemaru_related_movie_get.php	2009-03-24 04:15:49 UTC (rev 195)
@@ -0,0 +1,52 @@
+<?php
+function smarty_function_cinemaru_related_movie_get($param, &$smarty)
+{
+    global $xoopsDB;
+    
+    $mydirname = $param['dirname'];
+    
+    $columns = array(
+                     'id', 'title', 'file', 'image_file', 'total_time', 'file_type',
+                     'file_size', 'randam_code', 'desc', 'genre', 'valid', 'owner',
+                     'counter', 'comment', 'comment_up_time', 'reg_time',
+                     'mod_time', 'reg_user', 'mod_user'
+                     );
+    $c = array();
+    foreach ($columns as $val) {
+        $c[] = 'm.' . $val;
+    }
+    $c2 = join(', ', $c);
+    
+    $sql = 'SELECT DISTINCT ' . $c2 . ' FROM ' . $xoopsDB->prefix($mydirname . '_movie') . ' AS m, ';
+    $sql .= $xoopsDB->prefix($mydirname . '_tag_movie') . ' AS tm ';
+    $sql .= ' WHERE tm.movie_id = m.id';
+
+    if( isset($param['tag']) ) {
+        $tagarray = array();
+        $tagarray = explode(',', $param['tag']);
+        foreach( $tagarray as $val ) {
+           $haveTags[] = 'tm.tags_id = ' . intval($val);
+        }
+        $sql .= ' AND (' . implode( ' OR ', $haveTags ) . ') ';
+    }
+
+    $sql .= ' AND m.valid = 1';
+    
+    if( isset($param['own']) ) {
+        $sql .= ' AND m.id <> ' . intval($param['own']);
+    }
+    $sql .= ' ORDER BY m.reg_time DESC, counter DESC';
+
+    if( isset($param['limit']) && intval($param['limit']) >  0 ) {
+       $sql .= ' LIMIT 0,' . intval($param['limit']);
+    }
+    $result = $xoopsDB->query($sql);
+    
+    $list = array();
+    
+    while ($row = $arr = $xoopsDB->fetchArray($result)) {
+        $list[] = $row;
+    }
+    
+    $smarty->assign( "relate_info", $list );
+}




Cinemaru-svn メーリングリストの案内
Back to archive index