![]() |
|
||||||||||
|
|||||
|
Регистрация: Dec 2007
Сообщений: 1
|
Здравствуйте, Уважаемые!
Может ли кто-нибудь подсказать как реализовать во flash коннект к БД для выбора последних новостей и вывода их только картинками с сылками на полный документ. Вот есть модуль, который выводит скролом новости на php+mysql+JavaScript ?php
$width = $params->get( 'width', '120' );
$height = $params->get( 'height', '120' );
$backgroundcolor = $params->get( 'backgroundcolor', 'none' );
$padding = $params->get( 'padding', '2' );
$delayb4scroll = $params->get( 'delayb4scroll', '2000' );
$marqueespeed = $params->get( 'marqueespeed', '2' );
$pauseit = $params->get( 'pauseit', '1' );
?>
<style type="text/css">
#marqueecontainer{
position: relative;
width: <?php echo $width; ?>px; /*marquee width */
height: <?php echo $height; ?>px; /*marquee height */
background-color: <?php echo $backgroundcolor; ?>;
overflow: hidden;
padding: <?php echo $padding; ?>px;
padding-left: <?php echo $padding; ?>px;
}
</style>
<script type="text/javascript">
/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
var delayb4scroll=<?php echo $delayb4scroll; ?> //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=<?php echo $marqueespeed; ?> //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=<?php echo $pauseit; ?> //Pause marquee onMousever (0=no. 1=yes)?
////NO NEED TO EDIT BELOW THIS LINE////////////
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''
function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
else
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}
function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.top=0
marqueeheight=document.getElementById("marqueecontainer").offsetHeight
actualheight=cross_marquee.offsetHeight
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}
if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee
</script>
<?php
/**
* @version $Id: mod_newsflash.php 5071 2006-09-15 16:16:55Z friesengeist $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
require_once( $mainframe->getPath( 'front_html', 'com_content') );
if (!defined( '_JOS_NEWSFLASH_MODULE' )) {
/** ensure that functions are declared only once */
define( '_JOS_NEWSFLASH_MODULE', 1 );
function output_newsflash( &$row, &$params, &$access ) {
global $mainframe;
$row->text = $row->introtext;
$row->groups = '';
$row->readmore = (trim( $row->fulltext ) != '');
$row->metadesc = '';
$row->metakey = '';
$row->access = '';
$row->created = '';
$row->modified = '';
HTML_content::show( $row, $params, $access, 0 );
}
}
global $my, $mosConfig_shownoauth, $mosConfig_offset, $mosConfig_link_titles, $acl;
// Disable edit ability icon
$access = new stdClass();
$access->canEdit = 0;
$access->canEditOwn = 0;
$access->canPublish = 0;
$now = _CURRENT_SERVER_TIME;
$noauth = !$mainframe->getCfg( 'shownoauth' );
$nullDate = $database->getNullDate();
$catid = intval( $params->get( 'catid' ) );
$items = intval( $params->get( 'items', 0 ) );
$style = $params->get( 'style', 'flash' );
$moduleclass_sfx = $params->get( 'moduleclass_sfx' );
$link_titles = $params->get( 'link_titles', $mosConfig_link_titles );
$params->set( 'intro_only', 1 );
$params->set( 'hide_author', 1 );
$params->set( 'hide_createdate', 0 );
$params->set( 'hide_modifydate', 1 );
$params->set( 'link_titles', $link_titles );
// query to determine article count
$query = "SELECT a.id, a.introtext, a.fulltext , a.images, a.attribs, a.title, a.state"
."\n FROM #__content AS a"
."\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
."\n INNER JOIN #__sections AS s ON s.id = a.sectionid"
."\n WHERE a.state = 1"
. ( $noauth ? "\n AND a.access <= " . (int) $my->gid . " AND cc.access <= " . (int) $my->gid . " AND s.access <= " . (int) $my->gid : '' )
."\n AND (a.publish_up = " . $database->Quote( $nullDate ) . " OR a.publish_up <= " . $database->Quote( $now ) . " ) "
."\n AND (a.publish_down = " . $database->Quote( $nullDate ) . " OR a.publish_down >= " . $database->Quote( $now ) . " )"
."\n AND a.catid = " . (int) $catid
."\n AND cc.published = 1"
."\n AND s.published = 1"
."\n ORDER BY a.ordering"
;
$database->setQuery( $query, 0, $items );
$rows = $database->loadObjectList();
$numrows = count( $rows );
// check if any results returned
if ( $numrows ) {
switch ($style) {
case 'horiz':
echo '<div id="marqueecontainer" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">';
echo '<div id="vmarquee" style="position: absolute; width: 98%;">';
foreach ($rows as $row) {
output_newsflash( $row, $params, $access );
}
echo '</div>';
echo '</div>';
break;
case 'vert':
echo '<div id="marqueecontainer" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">';
echo '<div id="vmarquee" style="position: absolute; width: 98%;">';
foreach ($rows as $row) {
output_newsflash( $row, $params, $access );
}
echo '</div>';
echo '</div>';
break;
case 'flash':
default:
echo '<div id="marqueecontainer" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">';
echo '<div id="vmarquee" style="position: absolute; width: 98%;">';
srand ((double) microtime() * 1000000);
$flashnum = rand( 0, $numrows-1 );
$row = $rows[$flashnum];
output_newsflash( $row, $params, $access );
echo '</div>';
echo '</div>';
break;
}
}
?>
И работает ли вообще flash с базами данных? Спасибо! |
|
|||||
|
Регистрация: May 2003
Адрес: Tallinn
Сообщений: 3,182
|
легко:
1. посылаете запрос php 2. пхп работает с базой и формирует из ассоциативного массива строку 3. передают флэшу 4. флэш парсит, разбивая строку на солжные или простые объекты (зависит от ответа сервера) Вот один из вариантов |
![]() |
![]() |
Часовой пояс GMT +4, время: 08:32. |
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | |
| Опции просмотра | |
|
|