Dotclear


Ignore:
Timestamp:
07/21/11 13:40:00 (14 years ago)
Author:
Franck <carnet.franck.paul@…>
Branch:
themes
Message:

Nouvelle gestion des stickers, step 1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • themes/ductile/_config.php

    r601 r604  
    1313 
    1414l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/admin'); 
     15 
     16$img_url = $core->blog->settings->system->themes_url.'/'.$core->blog->settings->system->theme.'/img/'; 
     17$img_path = dirname(__FILE__).'/img/'; 
    1518 
    1619$list_types = array( 
     
    108111); 
    109112 
    110 $ductile_user = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_style'); 
    111 $ductile_user = @unserialize($ductile_user); 
    112 if (!is_array($ductile_user)) { 
    113      $ductile_user = array(); 
    114 } 
    115  
    116 $ductile_user = array_merge($ductile_base,$ductile_user); 
    117  
    118 $ductile_stickers_base = array( 
    119      array('label' => null,'url' => null,'image' => null), 
    120      array('label' => null,'url' => null,'image' => null), 
    121      array('label' => null,'url' => null,'image' => null) 
    122 ); 
    123  
    124 $ductile_stickers = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers'); 
    125 $ductile_stickers = @unserialize($ductile_stickers); 
    126 if (!is_array($ductile_stickers)) { 
    127      $ductile_stickers = $ductile_stickers_base; 
    128 } 
    129  
    130113$ductile_lists_base = array( 
    131114     'default' => null, 
     
    137120); 
    138121 
    139 $ductile_lists = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_lists'); 
    140 $ductile_lists = @unserialize($ductile_lists); 
    141 if (!is_array($ductile_lists)) { 
    142      $ductile_lists = $ductile_lists_base; 
    143 } 
    144  
    145122$ductile_counts_base = array( 
    146123     'default' => null, 
     
    149126     'search' => null 
    150127); 
    151  
    152 $ductile_counts = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_counts'); 
    153 $ductile_counts = @unserialize($ductile_counts); 
    154 if (!is_array($ductile_counts)) { 
    155      $ductile_counts = $ductile_counts_base; 
    156 } 
    157  
    158128 
    159129$conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html'; 
     
    167137               $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']); 
    168138                
    169                $count = 0; 
    170                if (!empty($_POST['sticker1_label']) && !empty($_POST['sticker1_url'])) { 
    171                     $ductile_stickers[$count]['label'] = $_POST['sticker1_label']; 
    172                     $ductile_stickers[$count]['url'] = $_POST['sticker1_url']; 
    173                     $ductile_stickers[$count]['image'] = $_POST['sticker1_image']; 
    174                     $count++; 
    175                } 
    176                if (!empty($_POST['sticker2_label']) && !empty($_POST['sticker2_url'])) { 
    177                     $ductile_stickers[$count]['label'] = $_POST['sticker2_label']; 
    178                     $ductile_stickers[$count]['url'] = $_POST['sticker2_url']; 
    179                     $ductile_stickers[$count]['image'] = $_POST['sticker2_image']; 
    180                     $count++; 
    181                } 
    182                if (!empty($_POST['sticker3_label']) && !empty($_POST['sticker3_url'])) { 
    183                     $ductile_stickers[$count]['label'] = $_POST['sticker3_label']; 
    184                     $ductile_stickers[$count]['url'] = $_POST['sticker3_url']; 
    185                     $ductile_stickers[$count]['image'] = $_POST['sticker3_image']; 
    186                     $count++; 
    187                } 
    188                for ($i = $count; $i < 3; $i++) { 
    189                     $ductile_stickers[$i]['label'] = null; 
    190                     $ductile_stickers[$i]['url'] = null; 
    191                     $ductile_stickers[$i]['image'] = null; 
     139               $ductile_stickers = array(); 
     140               for ($i = 0; $i < count($_POST['sticker_label']); $i++) { 
     141                    if (!empty($_POST['sticker_label'][$i]) && !empty($_POST['sticker_url'][$i])) { 
     142                         $ductile_stickers[] = array( 
     143                              'label' => $_POST['sticker_label'][$i], 
     144                              'url' => $_POST['sticker_url'][$i], 
     145                              'image' => $_POST['sticker_image'][$i] 
     146                         ); 
     147                    } 
    192148               } 
    193149 
     
    253209} 
    254210 
     211$ductile_user = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_style'); 
     212$ductile_user = @unserialize($ductile_user); 
     213if (!is_array($ductile_user)) { 
     214     $ductile_user = array(); 
     215} 
     216 
     217$ductile_user = array_merge($ductile_base,$ductile_user); 
     218 
     219$ductile_stickers = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers'); 
     220$ductile_stickers = @unserialize($ductile_stickers); 
     221$ductile_stickers_full = array(); 
     222if (is_array($ductile_stickers)) { 
     223     foreach ($ductile_stickers as $k => $v) { 
     224          $ductile_stickers_full[$v['image']] = array('label' => $v['label'],'url' => $v['url']); 
     225     } 
     226} 
     227// Get all sticker-*.png in img folder of theme 
     228$ductile_stickers_images = files::scandir($img_path); 
     229if (is_array($ductile_stickers_images)) { 
     230     foreach ($ductile_stickers_images as $v) { 
     231          if (preg_match('/^sticker\-(.*)\.png$/',$v)) { 
     232               if (!array_key_exists($v,$ductile_stickers_full)) { 
     233                    // image not used by a saved sticker 
     234                    $ductile_stickers_full[$v] = array('label' => null,'url' => null); 
     235               } 
     236          } 
     237     } 
     238} 
     239 
     240$ductile_lists = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_lists'); 
     241$ductile_lists = @unserialize($ductile_lists); 
     242if (!is_array($ductile_lists)) { 
     243     $ductile_lists = $ductile_lists_base; 
     244} 
     245 
     246$ductile_counts = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_counts'); 
     247$ductile_counts = @unserialize($ductile_counts); 
     248if (!is_array($ductile_counts)) { 
     249     $ductile_counts = $ductile_counts_base; 
     250} 
     251 
    255252// To be deleted when adminThemeConfigManaged behaviour will be implemented in admin/blog_themes.php : 
    256253echo '</form>'; 
     
    268265 
    269266echo '<fieldset><legend>'.__('Stickers').'</legend>'; 
    270  
    271 $img_url = $core->blog->settings->system->themes_url.'/'.$core->blog->settings->system->theme.'/img/'; 
    272267 
    273268echo '<table id="stickerslist">'.'<caption>'.__('Stickers (footer)').'</caption>'. 
     
    275270'<tr>'. 
    276271'<th scope="col">'.__('Position').'</th>'. 
     272'<th scope="col">'.__('Image').'</th>'. 
    277273'<th scope="col">'.__('Label').'</th>'. 
    278274'<th scope="col">'.__('URL').'</th>'. 
    279 '<th scope="col">'.__('Icon').'</th>'. 
    280 '<th>'.'</th>'. 
    281275'</tr>'. 
    282276'</thead>'. 
    283 '<tbody>'. 
    284 '<tr>'. 
    285 '<td scope="raw">1</td>'. 
    286 '<td>'.form::field('sticker1_label',20,255,$ductile_stickers[0]['label']).'</td>'. 
    287 '<td>'.form::field('sticker1_url',40,255,$ductile_stickers[0]['url']).'</td>'. 
    288 '<td>'.form::combo('sticker1_image',$sticker_images,$ductile_stickers[0]['image']).'</td>'. 
    289 '<td>'.'<img src="'.$img_url.$ductile_stickers[0]['image'].'" />'.'</td>'. 
    290 '</tr>'. 
    291 '<tr>'. 
    292 '<td scope="raw">2</td>'. 
    293 '<td>'.form::field('sticker2_label',20,255,$ductile_stickers[1]['label']).'</td>'. 
    294 '<td>'.form::field('sticker2_url',40,255,$ductile_stickers[1]['url']).'</td>'. 
    295 '<td>'.form::combo('sticker2_image',$sticker_images,$ductile_stickers[1]['image']).'</td>'. 
    296 '<td>'.'<img src="'.$img_url.$ductile_stickers[1]['image'].'" />'.'</td>'. 
    297 '</td>'. 
    298 '</tr>'. 
    299 '<tr>'. 
    300 '<td scope="raw">3</td>'. 
    301 '<td>'.form::field('sticker3_label',20,255,$ductile_stickers[2]['label']).'</td>'. 
    302 '<td>'.form::field('sticker3_url',40,255,$ductile_stickers[2]['url']).'</td>'. 
    303 '<td>'.form::combo('sticker3_image',$sticker_images,$ductile_stickers[2]['image']).'</td>'. 
    304 '<td>'.'<img src="'.$img_url.$ductile_stickers[2]['image'].'" />'.'</td>'. 
    305 '</td>'. 
    306 '</tr>'. 
     277'<tbody>'; 
     278$count = 1; 
     279foreach ($ductile_stickers_full as $k => $v) { 
     280     echo  
     281     '<tr>'. 
     282     '<td>'.form::field(array('sticker_position[]'),2,3,$count++).'</td>'. 
     283     '<td>'.form::hidden(array('sticker_image[]'),$k).'<img src="'.$img_url.$k.'" /> '.'</td>'. 
     284     '<td scope="raw">'.form::field(array('sticker_label[]'),20,255,$v['label']).'</td>'. 
     285     '<td>'.form::field(array('sticker_url[]'),40,255,$v['url']).'</td>'. 
     286     '</tr>'; 
     287} 
     288echo 
    307289'</tbody>'. 
    308290'</table>'; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map