Dotclear

Changeset 419:c22178d34030 for themes


Ignore:
Timestamp:
06/27/11 14:38:41 (14 years ago)
Author:
Franck <carnet.franck.paul@…>
Branch:
themes
Message:

Premier pas pour la gestion des stickers

Location:
themes/ductile
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • themes/ductile/_config.php

    r395 r419  
    1313 
    1414l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/main'); 
     15 
     16$sticker_images = array( 
     17     __('Contact') => 'sticker-contact.png', 
     18     __('Feed') => 'sticker-feed.png', 
     19     __('About') => 'sticker-about.png' 
     20); 
    1521 
    1622$fonts = array( 
     
    94100$ductile_user = array_merge($ductile_base,$ductile_user); 
    95101 
     102$ductile_stickers_base = array( 
     103     array('label' => null,'url' => null,'image' => null), 
     104     array('label' => null,'url' => null,'image' => null), 
     105     array('label' => null,'url' => null,'image' => null) 
     106); 
     107 
     108$ductile_stickers = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers'); 
     109$ductile_stickers = @unserialize($ductile_stickers); 
     110if (!is_array($ductile_stickers)) { 
     111     $ductile_stickers = array(); 
     112} 
     113 
     114$ductile_stickers = $ductile_stickers_base; 
     115 
    96116$conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html'; 
    97117 
     
    103123          if ($conf_tab == 'html') { 
    104124               $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']); 
     125                
     126               $count = 0; 
     127               if (!empty($_POST['sticker1_label']) && !empty($_POST['sticker1_url'])) { 
     128                    $ductile_stickers[$count]['label'] = $_POST['sticker1_label']; 
     129                    $ductile_stickers[$count]['url'] = $_POST['sticker1_url']; 
     130                    $ductile_stickers[$count]['image'] = $_POST['sticker1_image']; 
     131                    $count++; 
     132               } 
     133               if (!empty($_POST['sticker2_label']) && !empty($_POST['sticker2_url'])) { 
     134                    $ductile_stickers[$count]['label'] = $_POST['sticker2_label']; 
     135                    $ductile_stickers[$count]['url'] = $_POST['sticker2_url']; 
     136                    $ductile_stickers[$count]['image'] = $_POST['sticker2_image']; 
     137                    $count++; 
     138               } 
     139               if (!empty($_POST['sticker3_label']) && !empty($_POST['sticker3_url'])) { 
     140                    $ductile_stickers[$count]['label'] = $_POST['sticker3_label']; 
     141                    $ductile_stickers[$count]['url'] = $_POST['sticker3_url']; 
     142                    $ductile_stickers[$count]['image'] = $_POST['sticker3_image']; 
     143                    $count++; 
     144               } 
     145               for ($i = $count; $i < 3; $i++) { 
     146                    $ductile_stickers[$i]['label'] = null; 
     147                    $ductile_stickers[$i]['url'] = null; 
     148                    $ductile_stickers[$i]['image'] = null; 
     149               } 
    105150          } 
    106151           
     
    133178          $core->blog->settings->addNamespace('themes'); 
    134179          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_style',serialize($ductile_user)); 
     180          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_stickers',serialize($ductile_stickers)); 
    135181          $core->blog->triggerBlog(); 
    136182 
     
    159205'</fieldset>'; 
    160206 
     207//echo '<fieldset><legend>'.__('Stickers').'</legend>'; 
     208echo '<h3>'.__('Stickers').'</h3>'; 
     209 
     210echo '<table id="stickerslist">'.'<caption>'.__('Stickers').'</caption>'. 
     211'<thead>'. 
     212'<tr>'. 
     213'<th scope="col">'.__('Position').'</th>'. 
     214'<th scope="col">'.__('Label').'</th>'. 
     215'<th scope="col">'.__('URL').'</th>'. 
     216'<th scope="col">'.__('Icon').'</th>'. 
     217'</tr>'. 
     218'</thead>'. 
     219'<tbody>'. 
     220'<tr>'. 
     221'<td scope="raw">1</td>'. 
     222'<td>'.form::field('sticker1_label',20,255,$ductile_stickers[0]['label']).'</td>'. 
     223'<td>'.form::field('sticker1_url',40,255,$ductile_stickers[0]['url']).'</td>'. 
     224'<td>'.form::combo('sticker1_image',$sticker_images,$ductile_stickers[0]['image']).'</td>'. 
     225'</tr>'. 
     226'<tr>'. 
     227'<td scope="raw">2</td>'. 
     228'<td>'.form::field('sticker2_label',20,255,$ductile_stickers[1]['label']).'</td>'. 
     229'<td>'.form::field('sticker2_url',40,255,$ductile_stickers[1]['url']).'</td>'. 
     230'<td>'.form::combo('sticker2_image',$sticker_images,$ductile_stickers[1]['image']).'</td>'. 
     231'</tr>'. 
     232'<tr>'. 
     233'<td scope="raw">3</td>'. 
     234'<td>'.form::field('sticker3_label',20,255,$ductile_stickers[2]['label']).'</td>'. 
     235'<td>'.form::field('sticker3_url',40,255,$ductile_stickers[2]['url']).'</td>'. 
     236'<td>'.form::combo('sticker3_image',$sticker_images,$ductile_stickers[2]['image']).'</td>'. 
     237'</tr>'. 
     238'</tbody>'. 
     239'</table>'; 
     240 
     241//echo '</fieldset>'; 
     242 
    161243echo '<input type="hidden" name="conf_tab" value="html">'; 
    162244echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>'; 
  • themes/ductile/_public.php

    r394 r419  
    1313if (!defined('DC_RC_PATH')) { return; } 
    1414 
     15# Behaviors 
    1516$core->addBehavior('publicHeadContent',array('tplDuctileTheme','publicHeadContent')); 
     17 
     18# Template items 
     19$core->tpl->addValue('Stickers',array('tplDuctileTheme','showStickers')); 
    1620 
    1721class tplDuctileTheme 
    1822{ 
     23     public static function showStickers($attr) 
     24     { 
     25          $res = ''; 
     26          $default = false; 
     27          $img_url = $GLOBALS['core']->blog->settings->system->themes_url.'/'.$GLOBALS['core']->blog->settings->system->theme.'/img/'; 
     28 
     29          $s = $GLOBALS['core']->blog->settings->themes->get($GLOBALS['core']->blog->settings->system->theme.'_stickers'); 
     30 
     31          if ($s === null) { 
     32               $default = true; 
     33          } else { 
     34               $s = @unserialize($s); 
     35               if (!is_array($s)) { 
     36                    $default = true; 
     37               } else { 
     38                    $s = array_filter($s,"self::cleanStickers"); 
     39                    if (count($s) == 0) { 
     40                         $default = true; 
     41                    } else { 
     42                         $count = 1; 
     43                         foreach ($s as $sticker) { 
     44                              $res .= self::setSticker($count,($count == count($s)),$sticker['label'],$sticker['url'],$img_url.$sticker['image']); 
     45                              $count++; 
     46                         } 
     47                    } 
     48               } 
     49          } 
     50 
     51          if ($default || $res == '') { 
     52               $res = self::setSticker(1,true,__('Feed'),$GLOBALS['core']->blog->url.$GLOBALS['core']->url->getBase('feed').'/atom',$img_url.'sticker-feed.png'); 
     53          } 
     54 
     55          if ($res != '') { 
     56               $res = '<ul id="stickers">'."\n".$res.'</ul>'."\n"; 
     57               return $res; 
     58          } 
     59     } 
     60      
     61     protected static function cleanStickers($s) 
     62     { 
     63          if (is_array($s)) { 
     64               if (isset($s['label']) && isset($s['url']) && isset($s['image'])) { 
     65                    if ($s['label'] != null && $s['url'] != null && $s['image'] != null) { 
     66                         return true; 
     67                    } 
     68               } 
     69          } 
     70          return false; 
     71     } 
     72      
     73     protected static function setSticker($position,$last,$label,$url,$image) 
     74     { 
     75          return '<li id="sticker'.$position.'"'.($last ? ' class="last"' : '').'>'."\n". 
     76               '<a href="'.$url.'">'."\n". 
     77               '<img alt="" src="'.$image.'" />'."\n". 
     78               '<span>'.$label.'</span>'."\n". 
     79               '</a>'."\n". 
     80               '</li>'."\n"; 
     81     } 
     82 
    1983     public static function publicHeadContent($core) 
    2084     { 
  • themes/ductile/tpl/_footer.html

    r401 r419  
    55--> 
    66 
     7<!--  
    78     <ul id="stickers"> 
    89          <li id="sticker1"><a href="{{tpl:BlogURL}}pages/Contact"><img src="{{tpl:BlogThemeURL}}/img/sticker-contact.png" alt="" /><span>Contact</span></a></li> 
     
    1011          <li id="sticker3" class="last"><a href="{{tpl:BlogURL}}pages/About"><img src="{{tpl:BlogThemeURL}}/img/sticker-about.png" alt="" /><span>À propos</span></a></li> 
    1112     </ul> 
     13--> 
     14     {{tpl:Stickers}} 
    1215 
    13   <p>{{tpl:SysPoweredBy}}</p> 
     16     <p>{{tpl:SysPoweredBy}}</p> 
    1417</div> 
    1518 
Note: See TracChangeset for help on using the changeset viewer.

Sites map