Не нравятся результаты поиска? Попробуйте другой поиск!
DLE FAQ » Все вопросы » Шаблоны (TPL) » Как добавить теги в shortstory.tpl?

Как добавить теги в shortstory.tpl?


     12.06.2016    Шаблоны (TPL), Хаки    599

вопрос
Есть теги из модуля "Афиша" {date-event}. Но эти теги работают не по всему сайту. Помогите пожалуйста вставить нужны код в show.short.php
Вот файл, в котором формируется сам тег:

<?php
/*
=====================================================    
http://www.dark5ider.ru/
-----------------------------------------------------
Copyright (c) 2013 dark5ider.ru
=====================================================
Файл: functions.php
-----------------------------------------------------
Назначение: Ряд функций для работы с модулем афиши
=====================================================
*/

if (!defined('DATALIFEENGINE'))
    {
    die("Hacking attempt!");
    }
    
function checkcat($afcat, $cat) {

    if(count(array_intersect(explode(",", $afcat), explode(",",$cat)))) return 1;
        else return 0;    
}    

function showcomelist ($id) {
    global  $db, $config, $user_group, $member_id;
    
    
    $event_users = dle_cache("events_who", $id);

if(!$event_users){


        $db->query("SELECT name,jointo FROM " . USERPREFIX . "_users WHERE jointo LIKE '%{$id}%'");
        
    while ($row = $db->get_row())
        {
        
        $join_arr = explode(',', $row['jointo']);
        if (in_array($id, $join_arr)) {
        
        if( $config['allow_alt_url']) $go_page = $config['http_home_url'] . "user/" . urlencode( $row['name'] ) . "/";                    
            else $go_page = "$PHP_SELF?subaction=userinfo&user=" . urlencode( $row['name'] );
        
        
$go_page = "onclick=\"ShowProfile('" . urlencode( $row['name'] ) . "', '" . htmlspecialchars( $go_page, ENT_QUOTES, $config['charset'] ) . "', '0'); return false;\"";
                
                if( $config['allow_alt_url']) $event_user = "<a {$go_page} href=\"" . $config['http_home_url'] . "user/" . urlencode( $row['name'] ) . "/\">" . $row['name'] . "</a>";
                else $event_user = "<a {$go_page} href=\"$PHP_SELF?subaction=userinfo&amp;user=" . urlencode( $row['name'] ) . "\">" . $row['name'] . "</a>";

            }
            
        if(!$event_users) $event_users .= $event_user; else $event_users .= ", ".$event_user;
            
        }
        
    $db->free();
    
}

    create_cache( "events_who", $event_users, $id);

return $event_users;
}

function showCalendar($cal_month, $cal_year){
    global $f, $r, $year, $db, $month, $config, $lang, $langdateshortweekdays, $PHP_SELF;
    
    $db->query("SELECT eventdate, title FROM ".PREFIX."_post WHERE approve='1' AND eventdate >= '{$year}-{$month}-01' AND eventdate < '{$year}-{$month}-01' + INTERVAL 1 MONTH");
    
    
    while($row = $db->get_row()){
        $events[date('j',strtotime($row['eventdate']))] = strtotime( $row['eventdate'] );
        $title[date('j',strtotime($row['eventdate']))] = stripslashes($row['title']);
    }

    $next = true;
    //if( intval( $cal_year . $cal_month ) >= date( 'Ym' )) $next = false;


    $cur_date=date( 'Ymj', time() + ($config['date_adjust'] * 60) );
    $cal_date = $cal_year.$cal_month;

    $cal_month = intval( $cal_month );
    $cal_year = intval( $cal_year );
    
    if( $cal_month < 0 ) $cal_month = 1;
    if( $cal_year < 0 ) $cal_year = 2012;
    
    $first_of_month = mktime( 0, 0, 0, $cal_month, 7, $cal_year );
    $maxdays = date( 't', $first_of_month ) + 1; // 28-31
    $prev_of_month = mktime( 0, 0, 0, ($cal_month - 1), 7, $cal_year );
    $next_of_month = mktime( 0, 0, 0, ($cal_month + 1), 7, $cal_year );
    $cal_day = 1;
    $weekday = date( 'w', $first_of_month ); // 0-6

    if( $config['allow_alt_url']) {
        
        $date_link['prev'] = '<a class="monthlink" onclick="doeventsCalendar(' . date( "'m','Y'", $prev_of_month ) . ',\'right\'); return false;" href="#" title="' . $lang['prev_moth'] . '">&laquo;</a>&nbsp;&nbsp;&nbsp;&nbsp;';
        $date_link['next'] = '&nbsp;&nbsp;&nbsp;&nbsp;<a class="monthlink" onclick="doeventsCalendar(' . date( "'m','Y'", $next_of_month ) . ',\'left\'); return false;" href="#" title="' . $lang['next_moth'] . '">&raquo;</a>';
    
    } else {
        
        $date_link['prev'] = '<a class="monthlink" onclick="doeventsCalendar(' . date( "'m','Y'", $prev_of_month ) . ',\'right\'); return false;" href="#" title="' . $lang['prev_moth'] . '">&laquo;</a>&nbsp;&nbsp;&nbsp;&nbsp;';
        $date_link['next'] = '&nbsp;&nbsp;&nbsp;&nbsp;<a class="monthlink" onclick="doeventsCalendar(' . date( "'m','Y'", $next_of_month ) . ',\'left\'); return false;" href="#" title="' . $lang['next_moth'] . '">&raquo;</a>';
    
    }
    
    if( ! $next ) $date_link['next'] = "&nbsp;&nbsp;&nbsp;&nbsp;&raquo;";
    
    $buffer = '<div id="calendar-events"><table id="calendar-events-t" cellpadding="3" class="calendar"><tr><th colspan="7" class="monthselect">' . $date_link['prev'] . langdate( 'F', $first_of_month ) . ' ' . $cal_year . $date_link['next'] . '</th></tr><tr>';
    
    //$buffer = '<div id="calendar-layer"><table id="calendar" cellpadding="3" class="calendar"><tr><th colspan="7" class="monthselect">'. langdate( 'F', $first_of_month ) . ' ' . $cal_year . '</th></tr><tr>';

    $buffer = str_replace( $f, $r, $buffer );

    
        # Дни недели: рабочая неделя
    for($it = 1; $it < 6; $it ++)
        $buffer .= '<th class="workday">' . $langdateshortweekdays[$it] . '</th>';
        
    # Дни недели: субботний и воскресный дни
    $buffer .= '<th class="weekday">' . $langdateshortweekdays[6] . '</th>';
    $buffer .= '<th class="weekday">' . $langdateshortweekdays[0] . '</th>';
    
    $buffer .= '</tr><tr>';
    
    if( $weekday > 0 ) {
        $buffer .= '<td colspan="' . $weekday . '">&nbsp;</td>';
    }

    while ( $maxdays > $cal_day ) {

        $cal_pos = $cal_date.$cal_day;

        if( $weekday == 7 ) {
            $buffer .= '</tr><tr>';
            $weekday = 0;
        }

# В данный день есть новость
        if( isset( $events[$cal_day] ) ) {
            $date['title'] = langdate( 'd F Y', $events[$cal_day] );
            
            # Если суббота и воскресенье.
            if( $weekday == '5' or $weekday == '6' ) {
                                
                $buffer .= '<td '.(($cal_pos==$cur_date)?' class="day-active day-current" ':' class="day-active" ').'><a onclick="showevents(' . date( "'".$cal_month."','Y','".$cal_day."'") . '); return false;" href="#" title="' . $title[$cal_day] . '">' . $cal_day . '</a></td>';
            
            }

            # Рабочии дни.
            else {
                
                $buffer .= '<td '.(($cal_pos==$cur_date)?' class="day-active-v day-current" ':' class="day-active-v" ').'><a onclick="showevents(' . date( "'".$cal_month."','Y','".$cal_day."'") . '); return false;" href="#" title="' . $title[$cal_day] . '">' . $cal_day . '</a></td>';
            
            }
        }

        # В данный день новостей нет.
        else {
            
            # Если суббота воскресенье
            if( $weekday == "5" or $weekday == "6" ) {
                $buffer .= '<td '.(($cal_pos==$cur_date)?' class="weekday day-current" ':' class="weekday" ').'>' . $cal_day . '</td>';
            }

            # Дни, когда ничего нет
            else {
                $buffer .= '<td '.(($cal_pos==$cur_date)?' class="day day-current" ':' class="day" ').'>' . $cal_day . '</td>';
            }
        }
        
        $cal_day ++;
        $weekday ++;
    }
    
    if( $weekday != 7 ) {
        $buffer .= '<td colspan="' . (7 - $weekday) . '">&nbsp;</td>';
    }
    
    return $buffer . '</tr></table></div>';

}

function shownext($days = 5, $load_tpl, $num = 1) {
    global  $f, $r, $year, $month, $lang, $config, $db, $tpl, $member_id, $user_group, $is_logged, $PHP_SELF;
    
    $tpl2      = new dle_template();
    $tpl2->dir = TEMPLATE_DIR;
    
        //$tpl2->result['nextevent'] = dle_cache("nextevent");
    
if(!$tpl2->result['nextevent']){
    
    $nextdate = strftime('%Y-%m-%d', mktime(0, 0, 0, date(n), date(j) + intval($days), date(Y)));
    
    $sql_query = $db->query("SELECT p.id, p.date, p.title, p.category, p.alt_name, p.short_story ,p.eventdate, p.comm_num, p.approve, p.fixed, e.news_read, e.votes FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE p.approve='1' AND eventdate <= '{$nextdate}' + INTERVAL 1 DAY AND eventdate > '" . date('Y-m-d') . "' ORDER BY p.eventdate  DESC, e.rating DESC, p.date DESC LIMIT 0," . intval($num) . "");
    
   // echo $db->num_rows($sql_query);
  
   if ($num>1 and $db->num_rows($sql_query)>1) $morethanone = true;
       else $morethanone = false;
    
    $i=0;
    
    while ($row = $db->get_row($sql_query)){
    
    
        $tpl2->load_template($load_tpl);
        $row['date'] = strtotime($row['date']);
        
        if( ! $row['category'] ) {
            $my_cat = "---";
            $my_cat_link = "---";
        } else {
            
            $my_cat = array ();
            $my_cat_link = array ();
            $cat_list = explode( ',', $row['category'] );

            if ($config['category_separator'] != ',') $config['category_separator'] = ' '.$config['category_separator'];
            
            if( count( $cat_list ) == 1 OR ($view_template == "rss" AND $config['rss_format'] == 2)) {
                
                $my_cat[] = $cat_info[$cat_list[0]]['name'];
                
                $my_cat_link = get_categories( $cat_list[0], $config['category_separator']);
            
            } else {
                
                foreach ( $cat_list as $element ) {
                    if( $element ) {
                        $my_cat[] = $cat_info[$element]['name'];
                        if( $config['allow_alt_url'] ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
                        else $my_cat_link[] = "<a href=\"$PHP_SELF?do=cat&category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
                    }
                }

                $my_cat_link = implode( "{$config['category_separator']} ", $my_cat_link );
            }
            
            $my_cat = implode( "{$config['category_separator']} ", $my_cat );
        }
        
        $row['category'] = intval($row['category']);
        
        $news_find = array(
            '{comments-num}' => $row['comm_num'],
            '{views}' => $row['news_read'],
            '{category}' => $my_cat,
            '{link-category}' => $my_cat_link,
            '{news-id}' => $row['id'],
            '{PAGEBREAK}' => ''
        );
        
        $tpl2->set('', $news_find);
        
        if ($cat_info[$row['category']]['icon'])
            {
            $tpl2->set('{category-icon}', $cat_info[$row['category']]['icon']);
            
            }
        else
            {
            $tpl2->set('{category-icon}', "{THEME}/dleimages/no_icon.gif");
            
            }
        
        if ($row['category'])
            $tpl2->set('{category-url}', $config['http_home_url'] . get_url($row['category']) . "/");
        else
            $tpl2->set('{category-url}', "#");
        
        if (date('Ymd', $row['date']) == date('Ymd', $_TIME))
            {
            $tpl2->set('{date}', $lang['time_heute'] . langdate(", H:i", $row['date']));
            
            }
        elseif (date('Ymd', $row['date']) == date('Ymd', ($_TIME - 86400)))
            {
            $tpl2->set('{date}', $lang['time_gestern'] . langdate(", H:i", $row['date']));
            
            }
        else
            {
            $tpl2->set('{date}', langdate($config['timestamp_active'], $row['date']));
            
            }
        
        $tpl2->copy_template = preg_replace("#\{date=(.+?)\}#ie", "langdate('\\1', '{$row['date']}')", $tpl2->copy_template);
        
        
        $tpl2->set('{date-event}', langdate($config['timestamp_active_afisha'], strtotime($row['eventdate'])));
        $tpl2->copy_template = preg_replace("#\{date-event=(.+?)\}#ie", "langdate('\\1', '".strtotime($row['eventdate'])."')", $tpl2->copy_template);

        
        
        if ($config['allow_tags'] and $row['tags'])
            {
            $tpl2->set('[tags]', "");
            $tpl2->set('[/tags]', "");
            
            $tags = array();
            
            $row['tags'] = explode(",", $row['tags']);
            
            foreach ($row['tags'] as $value)
                {
                $value = trim($value);
                
                if ($config['allow_alt_url'])
                    $tags[] = "<a href=\"" . $config['http_home_url'] . "tags/" . urlencode($value) . "/\">" . $value . "</a>";
                else
                    $tags[] = "<a href=\"$PHP_SELF?do=tags&amp;tag=" . urlencode($value) . "\">" . $value . "</a>";
                
                }
            
            $tpl2->set('{tags}', implode(", ", $tags));
            
            }
        else
            {
            $tpl2->set_block("'\\[tags\\](.*?)\\[/tags\\]'si", "");
            $tpl2->set('{tags}', "");
            
            }
        
        if ($row['allow_rate'])
            {
            if ($config['short_rating'] and $user_group[$member_id['user_group']]['allow_rating'])
                $tpl2->set('{rating}', ShowRating($row['id'], $row['rating'], $row['vote_num'], 1));
            else
                $tpl2->set('{rating}', ShowRating($row['id'], $row['rating'], $row['vote_num'], 0));
            
            $tpl2->set('{vote-num}', "<span id=\"vote-num-id-" . $row['id'] . "\">" . $row['vote_num'] . "</span>");
            $tpl2->set('[rating]', "");
            $tpl2->set('[/rating]', "");
            
            }
        else
            {
            $tpl2->set('{rating}', "");
            $tpl2->set('{vote-num}', "");
            $tpl2->set_block("'\\[rating\\](.*?)\\[/rating\\]'si", "");
            }
        
        if ($config['allow_alt_url'])
            {
            $go_page = $config['http_home_url'] . "user/" . urlencode($row['autor']) . "/";
            $tpl2->set('[day-news]', "<a href=\"" . $config['http_home_url'] . date('Y/m/d/', $row['date']) . "\" >");
            
            }
        else
            {
            $go_page = "$PHP_SELF?subaction=userinfo&amp;user=" . urlencode($row['autor']);
            $tpl2->set('[day-news]', "<a href=\"$PHP_SELF?year=" . date('Y', $row['date']) . "&amp;month=" . date('m', $row['date']) . "&amp;day=" . date('d', $row['date']) . "\" >");
            
            }
        
        $tpl2->set('[/day-news]', "</a>");
        $tpl2->set('[profile]', "<a href=\"" . $go_page . "\">");
        $tpl2->set('[/profile]', "</a>");
        
        $tpl2->set('{login}', $row['autor']);
        
        $tpl2->set('{author}', "<a onclick=\"ShowProfile('" . urlencode($row['autor']) . "', '" . $go_page . "', '" . $user_group[$member_id['user_group']]['admin_editusers'] . "'); return false;\" href=\"" . $go_page . "\">" . $row['autor'] . "</a>");
        
        if( $config['allow_alt_url'] ) {
            
            if( $config['seo_type'] == 1 OR $config['seo_type'] == 2  ) {
                
                if( $row['category'] and $config['seo_type'] == 2 ) {
                    
                    $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                } else {
                    
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                }
            
            } else {
                
                $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
            }
        
        } else {
            
            $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
        
        }
        
        if (($row['full_story'] < 13) and $config['hide_full_link'])
            $tpl2->set_block("'\\[full-link\\](.*?)\\[/full-link\\]'si", "");
        else
            {
            $tpl2->set('[full-link]', "<a href=\"" . $full_link . "\">");
            
            $tpl2->set('[/full-link]', "</a>");
            }
        
        $tpl2->set('{full-link}', $full_link);
        
        if ($row['allow_comm'])
            {
            $tpl2->set('[com-link]', "<a href=\"" . $full_link . "#comment\">");
            $tpl2->set('[/com-link]', "</a>");
            
            }
        else
            $tpl2->set_block("'\\[com-link\\](.*?)\\[/com-link\\]'si", "");
        
        if ($is_logged)
            {
            $fav_arr = explode(',', $member_id['favorites']);
            
            if (!in_array($row['id'], $fav_arr) or $config['allow_cache'])
                $tpl2->set('{favorites}', "<a id=\"fav-id-" . $row['id'] . "\" href=\"$PHP_SELF?do=favorites&amp;doaction=add&amp;id=" . $row['id'] . "\"><img src=\"" . $config['http_home_url'] . "templates/{$config['skin']}/dleimages/plus_fav.gif\" onclick=\"doFavorites('" . $row['id'] . "', 'plus'); return false;\" title=\"" . $lang['news_addfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>");
            else
                $tpl2->set('{favorites}', "<a id=\"fav-id-" . $row['id'] . "\" href=\"$PHP_SELF?do=favorites&amp;doaction=del&amp;id=" . $row['id'] . "\"><img src=\"" . $config['http_home_url'] . "templates/{$config['skin']}/dleimages/minus_fav.gif\" onclick=\"doFavorites('" . $row['id'] . "', 'minus'); return false;\" title=\"" . $lang['news_minfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>");
            
            $tpl2->set('[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'news')\">");
            $tpl2->set('[/complaint]', "</a>");
            
            
            }
        else
            {
            $tpl2->set('{favorites}', "");
            $tpl2->set_block("'\\[complaint\\](.*?)\\[/complaint\\]'si", "");
            }
        
        
        $row['title'] = stripslashes( $row['title'] );

            if ( preg_match( "#\\{title limit=['\"](.+?)['\"]\\}#i", $tpl2->copy_template, $matches ) ) {
                $count= intval($matches[1]);
                $row['title'] = strip_tags( $row['title'] );

                if( $count AND dle_strlen( $row['title'], $config['charset'] ) > $count ) {
                        
                    $row['title'] = dle_substr( $row['title'], 0, $count, $config['charset'] );
                        
                    if( ($temp_dmax = dle_strrpos( $row['title'], ' ', $config['charset'] )) ) $row['title'] = dle_substr( $row['title'], 0, $temp_dmax, $config['charset'] );
                    
                }

                $tpl2->set( $matches[0], $row['title'] );

        
            } else $tpl2->set( '{title}', $row['title'] );
        
        $row['short_story'] = stripslashes($row['short_story']);

            if (stripos ( $tpl2->copy_template, "{image-" ) !== false) {

                $images = array();
                preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['short_story'], $media);
                $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
    
                foreach($data as $url) {
                    $info = pathinfo($url);
                    if (isset($info['extension'])) {
                        $info['extension'] = strtolower($info['extension']);
                        if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
                    }
                }
    
                if ( count($images) ) {
                    $i_count=0;
                    foreach($images as $url) {
                        $i_count++;
                        $tpl2->copy_template = str_replace( '{image-'.$i_count.'}', $url, $tpl2->copy_template );
                        $tpl2->copy_template = str_replace( '[image-'.$i_count.']', "", $tpl2->copy_template );
                        $tpl2->copy_template = str_replace( '[/image-'.$i_count.']', "", $tpl2->copy_template );
                    }
    
                }
    
                $tpl2->copy_template = preg_replace( "#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is", "", $tpl2->copy_template );
                $tpl2->copy_template = preg_replace( "#\\{image-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl2->copy_template );
    
            }
            
if ( preg_match( "#\\{short-story limit=['\"](.+?)['\"]\\}#i", $tpl2->copy_template, $matches ) ) {
                $count= intval($matches[1]);
    
                $row['short_story'] = str_replace( "</p><p>", " ", $row['short_story'] );
                $row['short_story'] = strip_tags( $row['short_story'], "<br>" );
                $row['short_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $row['short_story'] ) ) ) ));
    
                if( $count AND dle_strlen( $row['short_story'], $config['charset'] ) > $count ) {
                        
                    $row['short_story'] = dle_substr( $row['short_story'], 0, $count, $config['charset'] );
                        
                    if( ($temp_dmax = dle_strrpos( $row['short_story'], ' ', $config['charset'] )) ) $row['short_story'] = dle_substr( $row['short_story'], 0, $temp_dmax, $config['charset'] );
                    
                }
    
                $tpl2->set( $matches[0], "<div id=\"news-id-" . $row['id'] . "\" style=\"display:inline;\">" . $row['short_story'] . "</div>" );
    
            } else    $tpl2->set( '{short-story}', "<div id=\"news-id-" . $row['id'] . "\" style=\"display:inline;\">" . $row['short_story'] . "</div>" );
        
        
        if ($user_group[$member_id['user_group']]['allow_hide'])
            $row['short_story'] = str_ireplace("[hide]", "", str_ireplace("[/hide]", "", $row['short_story']));
        else
            $row['short_story'] = preg_replace("#\[hide\](.+?)\[/hide\]#ims", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $row['short_story']);
        
        
        
        // Обработка дополнительных полей
        
        if ($xfound)
            {
            $xfieldsdata = xfieldsdataload($row['xfields']);
            
            foreach ($xfields as $value)
                {
                $preg_safe_name = preg_quote($value[0], "'");
                
                if ($value[6] AND !empty($xfieldsdata[$value[0]]))
                    {
                    $temp_array = explode(",", $xfieldsdata[$value[0]]);
                    $value3     = array();
                    
                    foreach ($temp_array as $value2)
                        {
                        $value2 = trim($value2);
                        $value2 = str_replace("&#039;", "'", $value2);
                        
                        if ($config['allow_alt_url'])
                            $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" . urlencode($value2) . "/\">" . $value2 . "</a>";
                        else
                            $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&amp;xf=" . urlencode($value2) . "\">" . $value2 . "</a>";
                        }
                    
                    $xfieldsdata[$value[0]] = implode(", ", $value3);
                    
                    unset($temp_array);
                    unset($value2);
                    unset($value3);
          &nb

Ответа пока нет


Чтобы комментировать - войдите или зарегистрируйтесь на сайте

Похожие вопросы

наверх