Jump to content

Aide svp deplacer jquerynewscroller dans 'header'


Recommended Posts

Bonsoir,

je voudrais deplacer jquerynewscroller dans 'header' , ou je peux modifier pour qu'il soit installer dans le header

parti php:

 

<?php

if( _PS_VERSION_ > '1.3.1.1' ) {

if (!defined('_CAN_LOAD_FILES_'))

exit;

}

 

class jquerynewscroller extends Module

{

function __construct()

{

$this->name = "jquerynewscroller";

$this->version = "1.1";

$this->author = "PrestaSpirit";

$this->tab = floatval(substr(_PS_VERSION_,0,3)) < 1.4 ? 'Prestaspirit' : 'advertising_marketing';

 

$this->_postErrors = array();

 

parent::__construct();

 

$this->displayName = $this->l("JQuery News Scroller");

$this->description = $this->l("Add block news scroller with JQuery").' - <a target="_blank" href="http://www.prestaspirit.fr" style="color: #268CCD;text-decoration: underline;">Prestaspirit.fr</a>';

$this->confirmUninstall = $this->l('Are you sure you want me to keep away from displaying content?');

 

if (self::isInstalled ($this->name) && $this->isConfigurable ())

{

$warning = $this->l ('Module not configured correctly');

if (!$this->_isConfigured($warning)

&& !empty($warning))

{

$this->warning .= $warning;

}

}

}

 

public function isConfigurable ()

{

return (int)method_exists($this, 'getContent') ? true : false;

}

 

protected function _isConfigured (&$warning)

{

$newsIsset = $this->_getNews();

if (empty($newsIsset))

{

$warning = $this->l('This module is not configured');

return false;

}

return true;

}

 

protected function setConfig($key,$value)

{

return Configuration::updateValue($key,$value,true);

}

 

protected function getConfig($value)

{

return Configuration::get($value);

}

 

protected function deleteConfig($value)

{

return Configuration::deleteByName($value);

}

 

function install()

{

if (!parent::install()

OR !$this->registerHook('footer')

OR !$this->registerHook('header')

OR !$this->createDB()

)

return false;

return true;

}

 

public function uninstall()

{

if (!parent::uninstall()

OR !$this->unregisterHook('footer')

OR !$this->unregisterHook ('header')

OR !Db::getInstance()->Execute('DROP TABLE `'._DB_PREFIX_.'jquerynewscroller`')

)

return false;

return true;

}

 

public function createDB()

{

$query = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'jquerynewscroller` (

`id` int(10) unsigned NOT NULL AUTO_INCREMENT,

`date` varchar(64) NOT NULL,

`link` varchar(64) NOT NULL,

`description` text,

PRIMARY KEY (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=utf8;';

if (!Db::getInstance()->Execute($query))

return false;

return true;

}

 

public function hookFooter($params)

{

global $smarty;

 

$smarty->assign(

array(

'newsData' => $this->_getNews()

)

);

return $this->display(__FILE__, 'jquerynewscroller.tpl');

}

 

public function hookHeader($params)

{

if (!$this->active)

{ return; }

 

 

if( _PS_VERSION_ > '1.4' )

{

Tools::addCSS(__PS_BASE_URI__ . 'modules/'.$this->name.'/css/li-scroller.css', 'all');

Tools::addJS(__PS_BASE_URI__ . 'modules/'.$this->name.'/js/jquery.li-scroller.1.0.js');

}

else{

return $this->display(__FILE__, $this->name.'-header.tpl');

}

}

 

private function _postProcess()

{

// Validate message

$id = Tools::getValue ('id', '');

$date = Tools::getValue ('date', '');

$link = Tools::getValue ('link', '');

$description = Tools::getValue ('description', '');

 

if (empty($description) || !Validate::isMessage ($description))

{

$this->_postErrors[] = $this->l('The description contains invalid html content');

}

 

// Save if no errors

if (!sizeof($this->_postErrors))

{

$db = Db::getInstance ();

if(!$id){

if (!$db->Execute('INSERT INTO `' . _DB_PREFIX_ . 'jquerynewscroller` (`date`, `link`, `description`) VALUES (\'' . pSQL($date) . '\', \'' . pSQL($link) . '\', \'' . pSQL($description) . '\')') || ($db->Affected_Rows() != 1))

return false;

}else{

if (!$db->Execute('UPDATE `' . _DB_PREFIX_ . 'jquerynewscroller` SET `date`=\'' . pSQL($date) . '\', `link`=\'' . pSQL($link) . '\', `description`=\'' . pSQL($description) . '\' WHERE `id`='.$id.''))

return false;

}

}

// return errors

if (!sizeof($this->_postErrors))

{

$this->_html .= '<div class="conf confirm">'.$this->l('Updated')."</div>";

}

else

{

$this->_html .= '<div class="alert error">';

foreach ($this->_postErrors as $err)

{

$this->_html .= $err.'<br />';

}

$this->_html .= "</div>";

}

return $this->_html;

}

 

public function getContent()

{

$this->_html .= "<h2>".$this->displayName."</h2>";

 

if (Tools::isSubmit("submit"))

{

$this->_postProcess();

}

 

$this->_displayForm();

 

return $this->_html;

}

 

public function _getNews($id = null){

if ($id) {

return Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'jquerynewscroller WHERE id='.$id);

}else{

return Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'jquerynewscroller');

}

}

 

public function _displayNews(){

global $currentIndex;

// Configuration

// Tbaleau des hook existant

$getNews = $this->_getNews();

if ($getNews) {

$this->_html.=

'<br /><fieldset style="background: none repeat scroll 0 0 #f8f8f8;border: 1px solid #dddddd;font-weight: 700;margin: 0;padding: 0.2em 0.5em;text-align: left;">

<legend style="background: none repeat scroll 0 0 #f8f8f8;border: 1px solid #dddddd;font-weight: 700;margin: 0;padding: 0.2em 0.5em;text-align: left;">

<img src="../img/admin/details.gif" alt="" class="middle" />' . $this->l('News existing') . '</legend>

<table class="table" style="width:100%;">

<tr>

<th>'.$this->l('date').'</th>

<th>'.$this->l('description').'</th>

<th>'.$this->l('link').'</th>

<th>'.$this->l('Actions').'</th>

</tr>';

foreach($getNews as $news):

$this->_html.= '<tr>

<td>'.$news['date'].'</td>

<td>'.$news['description'].'</td>

<td>'.$news['link'].'</td>

<td width="10%" class="center">

<a href="'.$currentIndex.'&configure='.$this->name.'&token='.((_PS_VERSION_ > '1.4') ? Tools::getAdminTokenLite('AdminModules') : Tools::getValue('token')).'&action=edit&id='.$news['id'].'" title="' . $this->l('Edit this news') . '">

<img src="../img/admin/edit.gif" alt="' . $this->l('Edit this news') . '" />

</a>

<a href="'.$currentIndex.'&configure='.$this->name.'&token='.((_PS_VERSION_ > '1.4') ? Tools::getAdminTokenLite('AdminModules') : Tools::getValue('token')).'&action=del&id='.$news['id'].'" title="' . $this->l('Delete this news') . '">

<img src="../img/admin/delete.gif" alt="' . $this->l('Delete this news') . '" />

</a>

</td>

</tr>';

endforeach;

$this->_html.=

'</table>

</fieldset>

';

return $this->_html;

}

}

 

private function _displayForm()

{

global $currentIndex, $smarty, $cookie;

 

$id = Tools::getValue('id');

$action = Tools::getValue('action');

$valueSubmit = (isset($action) && $action == 'edit') ? $this->l('Upgrade') : $this->l('Submit');

if ( $id && $action )

{

switch ( $action )

{

case 'edit':

$valueForm = $this->_getNews($id);

break;

 

case 'del':

Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'jquerynewscroller WHERE id='.$id);

break;

}

}

 

if (_PS_VERSION_ < '1.4') {

$this->_html .= '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript" charset="utf-8"></script>';

}

 

$this->_html .= '

<script type="text/javascript" src="'. __PS_BASE_URI__ . 'modules/'.$this->name.'/js/jquery-ui.min.js"></script>

<script type="text/javascript" src="'. __PS_BASE_URI__ . 'modules/'.$this->name.'/js/jquery.ui.datepicker-'. $cookie->id_lang .'.js"></script>

<link rel="stylesheet" href="'. __PS_BASE_URI__ . 'modules/'.$this->name.'/css/ui-lightness/jquery-ui.custom.css">

<script type="text/javascript">

$(function() {

$( "#datepicker" ).datepicker();

});

</script>

<form method="post" action="'.$currentIndex.'&configure='.$this->name.'&token='.((_PS_VERSION_ > '1.4') ? Tools::getAdminTokenLite('AdminModules') : Tools::getValue('token')).'">

<fieldset style="background: none repeat scroll 0 0 #f8f8f8;border: 1px solid #dddddd;font-weight: 700;margin: 0;padding: 0.2em 0.5em;text-align: left;">

<legend style="background: none repeat scroll 0 0 #f8f8f8;border: 1px solid #dddddd;font-weight: 700;margin: 0;padding: 0.2em 0.5em;text-align: left;">

<img src="../modules/jquerynewscroller/logo.gif" alt="" class="middle" />'.$this->l('Settings').'</legend>

<h4>' . $this->l('Add a news') . '</h4>

<label>'.$this->l('News date : ').'</label>

<div class="margin-form">

<input type="text" name="date" id="datepicker" value="'.$valueForm[0]['date'].'" />

</div>

<br />

<label>'.$this->l('News description : ').'</label>

<div class="margin-form">

<input type="text" name="description" value="'.$valueForm[0]['description'].'" size="75"/>

</div>

<br />

<label>'.$this->l('News link : ').'</label>

<div class="margin-form">

<input type="text" name="link" value="'.$valueForm[0]['link'].'" size="75" />

</div>

<br />

 

<br />

<center><input type="submit" name="submit" value="'. $valueSubmit .'" class="button" /></center>

</fieldset>

</form>

';

 

$this->_displayNews();

}

}

 

 

-------------------------------------------------------------------

parti .tpl

 

{if $newsData}

<script type="text/javascript">

{literal}

$(function(){

$("ul#newsticker01").liScroll();

});

{/literal}

</script>

<div class="mask">

<ul id="newsticker01" class="newsticker">

{foreach from=$newsData item=datanews}

<li>

<span>{$datanews.date}</span>

<a href="{$datanews.link}">{$datanews.description}</a>

</li>

{/foreach}

</ul>

</div>

{/if}

 

------------------------------------------------------------------------

 

parti css

 

/* liScroll styles */

 

.tickercontainer { /* the outer div with the black border */

border: 1px solid #D0D3D8;

background: #000;

width: 100%;

height: 27px;

margin: 20px auto;

padding: 0;

overflow: hidden;

.tickercontainer .mask { /* that serves as a mask. so you get a sort of padding both left and right */

position: relative;

left: 10px;

top: 8px;

width: 100%;

overflow: hidden;

}

ul.newsticker { /* that's your list */

position: relative;

left: 100%;

font: bold 10px Verdana;

list-style-type: none;

margin: 0;

padding: 0;

}

ul.newsticker li {

float: left; /* important: display inline gives incorrect results when you check for elem's width */

margin: 0;

padding: 0;

background: #000;

}

ul.newsticker a {

white-space: nowrap;

padding: 0;

color: #000;

font: bold 10px Verdana;

margin: 0 50px 0 0;

}

ul.newsticker span {

margin: 0 10px 0 0;

}

 

merci pour votre aide.

 

van

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...