Changeset 43

Show
Ignore:
Timestamp:
03/15/06 14:01:59 (2 years ago)
Author:
eadiaz
Message:

Support for youtube video content.
In the future we will enable more content type, we are using the is_micro_content field, 0 = url, 1=plain text (no url), 2=youtube video.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/public_html/akarru.lib/memes.php

    r38 r43  
    22include_once('lib/xmlrpc.inc'); 
    33include_once('lib/xmlrpcs.inc'); 
     4 
     5  function get_youtube($url) 
     6  { 
     7          $matches = array(); 
     8          @preg_match('/v=(.*)$/', $url, $matches); 
     9          if (empty($matches[1])) { 
     10                  return ''; 
     11          } 
     12          $url = 'http://youtube.com/v/'.$matches[1]; 
     13          return '<object width="300" height="250"><param name="movie" value="'.$url.'"></param><embed src="'.$url.'" type="application/x-shockwave-flash" width="300" height="250"></embed></object>';  
     14  } 
    415 
    516class memes { 
     
    8293        function get_meme($id) 
    8394        { 
    84                 $sql =  'select p.title,p.content,p.date_posted,p.date_promo,p.rank,p.clicks,p.category,p.url,p.submitted_user_id,p.ID,pc.cat_title,u.username, u.email, pc.ID as cat_id, p.votes as vote_count, comments as comment_count from posts p, post_cats pc, users u where pc.ID=p.category and u.ID=p.submitted_user_id '; 
     95                $sql =  'select p.title,p.is_micro_content,p.content,p.date_posted,p.date_promo,p.rank,p.clicks,p.category,p.url,p.submitted_user_id,p.ID,pc.cat_title,u.username, u.email, pc.ID as cat_id, p.votes as vote_count, comments as comment_count from posts p, post_cats pc, users u where pc.ID=p.category and u.ID=p.submitted_user_id '; 
    8596                $sql .= ' and p.ID='.$id; 
    8697                $result = $this->db->fetch_object($sql); 
    8798                $result->small_gravatar = get_gravatar($bm_url, $result->email, 16);  
     99                if ($result->is_micro_content == 2) { 
     100                        $result->micro_content = get_youtube($result->url); 
     101                } 
    88102                return $result; 
    89103        } 
     
    106120        function get_comments($meme_id) 
    107121        { 
    108                 $sql  = ' select c.title, c.content, c.date_posted, u.username, u.email '
     122                $sql  = ' select c.title, c.content, c.date_posted, u.username, u.email, c.post_id as ID '
    109123                $sql .= ' from post_comments c left join users u on c.user_id = u.ID '; 
    110124                $sql .= ' where post_id = '.$meme_id; 
     
    196210                        $meme_id = $meme->ID; 
    197211                        $uid = $this->user_id; 
    198                         if (empty($uid)) { 
    199                                 $uid = 0
     212                        if (!empty($uid) && !empty($meme_id)) { 
     213                                $meme->voted = $this->db->fetch_scalar("select count(*) from post_votes where post_id = $meme_id and user_id = $uid ")
    200214                        } 
    201                         $meme->voted = $this->db->fetch_scalar("select count(*) from post_votes where post_id = $meme_id and user_id = $uid "); 
     215                        $mc = $meme->is_micro_content; 
     216                        if ($mc == 2) { 
     217                                        $meme->micro_content = get_youtube($meme->url); 
     218                        } 
    202219                        $result[] = $meme; 
    203220                } 
     
    305322                $date_posted = time(); 
    306323                $trackback = $data['meme_trackback']; 
    307                 $sql  = 'insert into posts(title,content,date_posted,date_promo,category,url,submitted_user_id,trackback) '; 
    308                 $sql .= "values('$title','$content',$date_posted,$date_posted,$category,'$url',$user_id,'$trackback')"; 
     324                $content_type = $data['content_type']; 
     325                $sql  = 'insert into posts(title,content,date_posted,date_promo,category,url,submitted_user_id,trackback,is_micro_content) '; 
     326                $sql .= "values('$title','$content',$date_posted,$date_posted,$category,'$url',$user_id,'$trackback', $content_type)"; 
    309327                if ($this->db->execute($sql)) 
    310328                { 
  • trunk/public_html/post.php

    r8 r43  
    3232                 $title = $_POST['title']; 
    3333                 $url   = $_POST['url']; 
     34                 $smarty->assign('content_type',  $_POST['content_type']); 
    3435                 if (empty($title)) { 
    3536                         $smarty->assign('error_title', true); 
     
    5859         } 
    5960         elseif ($_POST['step'] == 2) { 
     61                 $smarty->assign('content_type',  $_POST['content_type']); 
    6062                 $title = $_POST['title']; 
    6163                 $url   = $_POST['url']; 
     
    8183                 $smarty->assign('meme_trackback', check_plain($meme_trackback)); 
    8284                 $smarty->assign('meme_tags', check_plain($meme_tags)); 
     85                 $smarty->assign('micro_content', get_youtube($url)); 
    8386                 if ($bm_errors == 0) { 
    8487                         $step = 3; 
     
    9194         } 
    9295         else if ($_POST['step'] == 3) { 
     96                 $smarty->assign('content_type',  $_POST['content_type']); 
    9397                 if (!empty($_POST['do_edit'])) { 
    9498                         $step = 2; 
     
    109113                         $smarty->assign('meme_tags', check_plain($meme_tags)); 
    110114                         $smarty->assign('cats', $bm_options); 
     115                         $smarty->assign('micro_content', get_youtube($url)); 
    111116                 } 
    112117                 else 
  • trunk/smarty/configs/site.conf

    r40 r43  
    11site_caption="Blog Memes" 
    22promote_label_url="promueve noticias" 
    3 post_label_url="env&iacute;a una noticia
     3post_label_url="env&iacute;a contenido
    44popular_label_url="lo m&aacute;s popular" 
    55unpopular_label_url="lo menos popular" 
     
    3838label_register_submit="registra cuenta" 
    3939label_recover_pass_submit="recuperar email" 
    40  
     40label_content_type="tipo de contenido:" 
    4141post_instructions='un meme es una unidad de transmisi&oacute;n cultural' 
    4242post_criteria='<ul><li><b>Calidad del contenido </b>¿Es relevante o interesante la historia que estás publicando?</li><li><b>¿Está escrita en Castellano o Español?</b></li><li><b>Se descriptivo:</b> Eres tu propio editor, se breve y explica porqué la historia a publicar es relevante.</li></ul>' 
  • trunk/smarty/templates/comment.tpl

    r26 r43  
    2323        {if $meme->vote_count > 7}&nbsp;|&nbsp <a href="circulation.php?meme_id={$meme->ID}">circulaci&oacute;n</a>{/if}</div> 
    2424        </div> 
     25        {if $meme->micro_content} 
     26        <div style="padding:2px">{$meme->micro_content}</div> 
     27        {/if} 
     28         
    2529          <p> 
    2630                  {$meme->content|nl2br} 
  • trunk/smarty/templates/memes_grid.tpl

    r36 r43  
    3232        &nbsp;{$meme->date_posted|date_format:$bf_date_posted}  
    3333        {if $meme->vote_count > 7}&nbsp;|&nbsp <a href="circulation.php?meme_id={$meme->ID}">circulaci&oacute;n</a>{/if}</div> 
     34         
    3435        <p style="right-margin:1em"> 
     36        {if $meme->micro_content} 
     37        <div style="padding:4px">{$meme->micro_content}</div> 
     38        {/if} 
    3539                  {$meme->content|nl2br} 
    3640          </p> 
  • trunk/smarty/templates/post_1.tpl

    r2 r43  
    1717{if $error_duplicate_url}<tr><td class="error">{#error_duplicate_url#}</td></tr>{/if} 
    1818{if $error_url}<tr><td class="error">{#error_url#}</td></tr>{/if} 
     19<tr><td class="view-label-class">{#label_content_type#}</td></tr> 
     20<tr><td> 
     21        <select class="view-input-class" name="content_type"> 
     22                <option value="0" selected="selected">url</option> 
     23                <option value="2">youtube</option> 
     24        </select> 
     25</td></tr> 
    1926<tr><td><input type="hidden" name="step" value="{$step}" /><input class="view-button-class" type="submit" value="{#post_submit_label#}" name="do_post" /> 
    2027</table> 
  • trunk/smarty/templates/post_2.tpl

    r2 r43  
    1818<tr><td><input class="view-input-class" value="{$meme_trackback}" name="meme_trackback" size="60" /></td></tr> 
    1919{if $error_trackback}<tr><td class="error">{#error_trackback#}</td></tr>{/if} 
    20 <tr><td><input type="hidden" name="step" value="{$step}" /> 
     20<tr><td><input type="hidden" name="content_type" value="{$content_type}" /><input type="hidden" name="step" value="{$step}" /> 
    2121<input class="view-button-class" type="submit" value="{#post_submit_label#}" name="do_post" /> 
    2222</td></tr> 
  • trunk/smarty/templates/post_3.tpl

    r2 r43  
    2222        style="font-size:10px" href="profile.php?user_name={$logged_username}">{$logged_username}</a> 
    2323        &nbsp;{$meme->date_posted|date_format:$bf_date_posted}</div> 
     24        {if $micro_content} 
     25        <div style="padding:2px">{$micro_content}</div> 
     26        {/if} 
    2427          <p> 
    2528                  {$content_body|nl2br} 
     
    3033        {if $meme_tags}etiquetas: {$meme_tags} &nbsp;|&nbsp; {/if}<input type="hidden" name="meme_tags" value="{$meme_tags}" /> {if $meme_trackback}| <a href="{$meme_trackback}" alt="{$meme_trackback}">trackback</a><input type="hidden" name="meme_trackback" value="{$meme_trackback}" />&nbsp;{/if} 
    3134        <input type="hidden" name="step" value="{$step}" />  
     35        <input type="hidden" name="content_type" value="{$content_type}" /> 
    3236        </div></td> 
    3337  </tr>