вопрос
Поставил модуль "Биография актеров" на DLE 10.6, вроде бы работает. Но при клике по актеру в тайтл не подставляется имя актера в фильмах которых от участвует. Например получается: "Все фильмы с участием" и все. Но если актер есть в базе, то получается нормально "Все фильмы с участием Том Хенкс". Как сделать, что бы в тайтле было имя актера даже если его нет в базе данных? А то автор не выходит на связь. Помогите пожалуйста..
Ковырять нужно в самом конце, в районе кода:
Ковырять нужно в самом конце, в районе кода:
$a_title = "Все фильмы с участием " . $actors[$a_name];
<?php
if (isset ( $_REQUEST['a_name'] )) $a_name = @$db->safesql ( strip_tags ( str_replace ( '/', '', $_GET['a_name'] ) ) ); else $a_name = '';
if (isset ( $_REQUEST['action'] )) $action = @$db->safesql ( strip_tags ( str_replace ( '/', '', $_GET['action'] ) ) ); else $action = '';
if ($action == 'biography' AND $a_name != ''){
$stop_news = TRUE;
if ($actors_config['b_cache'] == "no") $config['allow_cache'] = "no";
$tpl->result['content'] = dle_cache( "biography_" . $a_name, $config['skin'], true );
if (!$tpl->result['content']){
$row = $db->super_query("SELECT * FROM ".PREFIX."_actors WHERE alt_name='$a_name' LIMIT 0,1");
if ($row['id']) {
$a_title = "Биография " . $row['name'] . " (" . $row['fullname'] . ")";
$tpl->load_template( 'actors_biography.tpl' );
if ($row['genres']) {
$my_cat_link = array();
foreach ( explode( ',', $row['genres'] ) as $element ) {
if( $element ) {
if( $config['allow_alt_url'] == "yes" ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
else $my_cat_link[] = "<a href=\"{$config['http_home_url']}{$cat_info[$element]['alt_name']}/\" target=\"_blank\">{$cat_info[$element]['name']}</a>";
}
}
$my_cat_link = implode( ', ', $my_cat_link );
}
if (! empty ( $row ['foto'] ))
if(fopen($config['http_home_url'] . "uploads/actors/posters/mini/". $row['foto'], "r"))
$tpl->set('{foto}',"<a href=\"{$config['http_home_url']}uploads/actors/posters/{$row['foto']}\" onclick=\"return hs.expand(this)\"><img src=\"{$config['http_home_url']}uploads/actors/posters/mini/{$row['foto']}\" style=\"border:none;\"></a>");
else
$tpl->set('{foto}',"<img align=\"left\" src=\"{$config['http_home_url']}uploads/actors/posters/{$row['foto']}\" border=\"0\">");
else
$tpl->set('{foto}',"");
function birthday ($birthday){
list($year,$month,$day) = explode("-",$birthday);
$year_diff = date("Y") - $year;
$month_diff = date("m") - $month;
$day_diff = date("d") - $day;
if ($day_diff < 0 || $month_diff < 0)
$year_diff--;
return $year_diff;
}
if ($member_id['user_group'] == 1) {
$tpl->set('{edit}', "<div style=\"float:right; padding:10px;\"><a href=\"{$config['http_home_url']}{$config['admin_path']}?mod=actors&action=edit&id=".$row['id']."\" target=\"_blank\"><img src=\"{$config['http_home_url']}engine/skins/images/actors_tools.png\" style=\"border:none;\"></a></div>");
} else {
$tpl->set('{edit}', "");
}
require_once (ENGINE_DIR . ('/modules/actors_biography.php'));
$tpl->set('{name}', stripslashes($row['name']));
$tpl->set('{fullname}', stripslashes($row['fullname']));
$tpl->set('{biography}', stripslashes($row['biography']));
$tpl->set('{genres}', $my_cat_link);
$tpl->set('{birthplace}', stripslashes($row['birthplace']));
$tpl->set('{date}', date("d.m.Y", strtotime($row['birthday'])));
$tpl->set("{years}", birthday($row['birthday']));
$tpl->set('{birthdayded}', stripslashes($row['birthdayded']));
$tpl->set('{height}', stripslashes($row['height']));
$tpl->set('{zodiak}', stripslashes($row['zodiak']));
$tpl->set('{karer}', stripslashes($row['karer']));
$tpl->set('{love}', stripslashes($row['love']));
$tpl->set('{id_kp}', stripslashes($row['id_kp']));
$tpl->set('{suprug}', stripslashes($row['suprug']));
$tpl->set('{supruga}', stripslashes($row['supruga']));
$tpl->set('{mestoumer}', stripslashes($row['mestoumer']));
$sql_f = $db->query("SELECT id, title, category, alt_name, xfields, short_story, date FROM ".PREFIX."_post WHERE actors LIKE '%{$a_name}%' LIMIT 0, 5");
if ($db->num_rows($sql_f) > 0) {
$tpl2 = new dle_template();
$tpl2->dir = TEMPLATE_DIR;
$tpl2->load_template( 'actors_story.tpl' );
while ($row_f = $db->get_row($sql_f)) {
if (strpos ( $tpl2->copy_template, "{image-" ) !== false) {
$images = array();
preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row_f['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=0;
foreach($images as $url) {
$i++;
$tpl2->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl2->copy_template );
$tpl2->copy_template = str_replace( '[image-'.$i.']', "", $tpl2->copy_template );
$tpl2->copy_template = str_replace( '[/image-'.$i.']', "", $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( "#\\{text limit=['\"](.+?)['\"]\\}#i", $tpl2->copy_template, $matches ) ) {
$count= intval($matches[1]);
$row_f['short_story'] = str_replace( "</p><p>", " ", $row_f['short_story'] );
$row_f['short_story'] = strip_tags( $row_f['short_story'], "<br>" );
$row_f['short_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $row_f['short_story'] ) ) ) ));
if( $count AND dle_strlen( $row_f['short_story'], $config['charset'] ) > $count ) {
$row_f['short_story'] = dle_substr( $row_f['short_story'], 0, $count, $config['charset'] );
if( ($temp_dmax = dle_strrpos( $row_f['short_story'], ' ', $config['charset'] )) ) $row_f['short_story'] = dle_substr( $row_f['short_story'], 0, $temp_dmax, $config['charset'] );
}
$tpl2->set( $matches[0], $row_f['short_story'] );
} else $tpl2->set( '{text}', $row_f['short_story'] );
if( $xfound ) {
$xfieldsdata = xfieldsdataload( $row_f['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("'", "'", $value2);
if( $config['allow_alt_url'] == "yes" ) $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" . urlencode( $value2 ) . "/\">" . $value2 . "</a>"; else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
}
$xfieldsdata[$value[0]] = implode(", ", $value3);
unset($temp_array);
unset($value2);
unset($value3);
}
if( empty( $xfieldsdata[$value[0]] ) ) {
$tpl2->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl2->copy_template );
$tpl2->copy_template = str_replace( "[xfnotgiven_{$preg_safe_name}]", "", $tpl2->copy_template );
$tpl2->copy_template = str_replace( "[/xfnotgiven_{$preg_safe_name}]", "", $tpl2->copy_template );
} else {
$tpl2->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl2->copy_template );
$tpl2->copy_template = str_replace( "[xfgiven_{$preg_safe_name}]", "", $tpl2->copy_template );
$tpl2->copy_template = str_replace( "[/xfgiven_{$preg_safe_name}]", "", $tpl2->copy_template );
}
$tpl2->copy_template = str_replace( "[xfvalue_{$preg_safe_name}]", stripslashes( $xfieldsdata[$value[0]] ), $tpl2->copy_template );
}
}
$row_f['date'] = strtotime($row_f['date']);
if( date( 'Ymd', $row_f['date'] ) == date( 'Ymd', $_TIME ) )
$tpl2->set( '{date}', $lang['time_heute'] . langdate( ", H:i", $row_f['date'] ) );
elseif( date( 'Ymd', $row_f['date'] ) == date( 'Ymd', ($_TIME - 86400) ) )
$tpl2->set( '{date}', $lang['time_gestern'] . langdate( ", H:i", $row_f['date'] ) );
else
$tpl2->set( '{date}', langdate( $config['timestamp_active'], $row_f['date'] ) );
if( ! $row_f['category'] ) {
$my_cat = "---";
$my_cat_link = "---";
} else {
$my_cat = array ();
$my_cat_link = array ();
$cat_list = explode( ',', $row_f['category'] );
if( count( $cat_list ) == 1 ) {
$my_cat[] = $cat_info[$cat_list[0]]['name'];
$my_cat_link = get_categories( $cat_list[0] );
} else {
foreach ( $cat_list as $element ) {
if( $element ) {
$my_cat[] = $cat_info[$element]['name'];
if( $config['allow_alt_url'] == "yes" ) $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( ', ', $my_cat_link );
}
$my_cat = implode( ', ', $my_cat );
}
if( $config['allow_alt_url'] == "yes" ) {
if( $row_f['flag'] and $config['seo_type'] ) {
if( $row_f['category'] and $config['seo_type'] == 2 )
$full_link = $config['http_home_url'] . get_url( $cat_list[0] ) . "/" . $row_f['id'] . "-" . $row_f['alt_name'] . ".html";
else
$full_link = $config['http_home_url'] . $row_f['id'] . "-" . $row_f['alt_name'] . ".html";
} else
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row_f['date'] ) . $row_f['alt_name'] . ".html";
} else
$full_link = $config['http_home_url'] . $row_f['id'] . "-" . $row_f['alt_name'] . ".html";
$tpl2->set( '[full-link]', "<a href=\"" . $full_link . "\">" );
$tpl2->set( '[/full-link]', "</a>" );
$tpl2->set("{title}", $row_f['title']);
$tpl2->set("{category}", $my_cat_link);
$tpl2->compile( 'films' );
}
$db->free($sql_f);
} else
$tpl->set_block( "'\\[films\\](.*?)\\[/films\\]'si", "" );
$tpl->set("{films}", $tpl2->result['films']); unset($tpl12); $db->free($sql_f);
$config['allow_alt_url'] == "yes" ? $link_a = $config['http_home_url'] . "films/" . $row['alt_name'] . "/" : $link_a = $config['http_home_url'] . "films/" . $row['alt_name'] . "/";
$tpl->set_block( "'\\[films-link\\](.*?)\\[/films-link\\]'si", "<a href=\"" . $link_a . "\" title=\"Все фильмы с {$row['name']}\">\\1</a>" );
$db->free($row);
$tpl->compile( 'content' );
$tpl->clear();
create_cache( "biography_" . $a_name, $tpl->result['content'], $config['skin'], true );
} else
msgbox("Ошибка", "Информации об этом актере / актрисе в базе отсутствует. Скорректируйте ваш запрос или попробуйте позже");
}
} elseif ($action == 'select' AND $a_name != '') {
$a_title = "Все фильмы с участием " . $actors[$a_name];
if ($cstart) {
$cstart = $cstart - 1;
$cstart = $cstart * $actors_config['f_number'];
}
$newsmodule = true;
$user_query = "do=actors&action=select&a_name=" . $a_name;
$url_page = $config['http_home_url'] . "films/" . $a_name;
if (isset ( $_SESSION['dle_sort_lastnews'] )) $news_sort_by = $_SESSION['dle_sort_lastnews'];
else $news_sort_by = "date";
if (isset ( $_SESSION['dle_direction_lastnews'] )) $news_direction_by = $_SESSION['dle_direction_lastnews'];
else $news_direction_by = "DESC";
$where = "actors LIKE '%{$a_name}%'";
if ($where){
$sql_select = "SELECT id, autor, date, short_story, SUBSTRING(full_story, 1, 15) as full_story, xfields, title, actors, category, alt_name, comm_num, allow_comm, approve, tags FROM " . PREFIX . "_post WHERE {$stop_list}approve=1 AND " . $where . $where_date . " ORDER BY " . $news_sort_by . " " . $news_direction_by . " LIMIT " . $cstart . "," . $config['news_number'];
$sql_count = "SELECT COUNT(*) as count FROM " . PREFIX . "_post WHERE {$stop_list}approve=1 AND " . $where. $where_date;
} else {
msgbox("Ошибка", "Информации об этом актере / актрисе в базе отсутствует. Скорректируйте ваш запрос или попробуйте позже");
$stop_news = TRUE;
}
} else
msgbox("Ошибка", "Информации об этом актере / актрисе в базе отсутствует. Скорректируйте ваш запрос или попробуйте позже");
?>
Ответил: Sander
$a_title = "Все фильмы с участием " . $actors[$a_name];
Заменить на
$a_title = "Все фильмы с участием " . ($actors[$a_name]?$actors[$a_name]:$a_name);