Changeset 605:2fc355faae09
- Timestamp:
- 07/21/11 15:42:19 (14 years ago)
- Branch:
- themes
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
themes/ductile/_config.php
r604 r605 127 127 ); 128 128 129 $ductile_user = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_style'); 130 $ductile_user = @unserialize($ductile_user); 131 if (!is_array($ductile_user)) { 132 $ductile_user = array(); 133 } 134 $ductile_user = array_merge($ductile_base,$ductile_user); 135 136 $ductile_lists = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_lists'); 137 $ductile_lists = @unserialize($ductile_lists); 138 if (!is_array($ductile_lists)) { 139 $ductile_lists = $ductile_lists_base; 140 } 141 142 $ductile_counts = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_counts'); 143 $ductile_counts = @unserialize($ductile_counts); 144 if (!is_array($ductile_counts)) { 145 $ductile_counts = $ductile_counts_base; 146 } 147 148 $ductile_stickers = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers'); 149 $ductile_stickers = @unserialize($ductile_stickers); 150 151 $ductile_stickers_full = array(); 152 // Get all sticker images already used 153 if (is_array($ductile_stickers)) { 154 foreach ($ductile_stickers as $v) { 155 $ductile_stickers_full[] = $v['image']; 156 } 157 } 158 // Get all sticker-*.png in img folder of theme 159 $ductile_stickers_images = files::scandir($img_path); 160 if (is_array($ductile_stickers_images)) { 161 foreach ($ductile_stickers_images as $v) { 162 if (preg_match('/^sticker\-(.*)\.png$/',$v)) { 163 if (!in_array($v,$ductile_stickers_full)) { 164 // image not already used 165 $ductile_stickers[] = array( 166 'label' => null, 167 'url' => null, 168 'image' => $v); 169 } 170 } 171 } 172 } 173 129 174 $conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html'; 130 175 … … 136 181 if ($conf_tab == 'html') { 137 182 $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']); 138 183 139 184 $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] 185 for ($i = 0; $i < count($_POST['sticker_image']); $i++) { 186 $ductile_stickers[] = array( 187 'label' => $_POST['sticker_label'][$i], 188 'url' => $_POST['sticker_url'][$i], 189 'image' => $_POST['sticker_image'][$i] 190 ); 191 } 192 193 $order = array(); 194 if (empty($_POST['ds_order']) && !empty($_POST['order'])) { 195 $order = $_POST['order']; 196 asort($order); 197 $order = array_keys($order); 198 } 199 if (!empty($order)) { 200 $new_ductile_stickers = array(); 201 foreach ($order as $i => $k) { 202 $new_ductile_stickers[] = array( 203 'label' => $ductile_stickers[$k]['label'], 204 'url' => $ductile_stickers[$k]['url'], 205 'image' => $ductile_stickers[$k]['image'] 146 206 ); 147 207 } 148 } 149 208 $ductile_stickers = $new_ductile_stickers; 209 } 210 150 211 for ($i = 0; $i < count($_POST['list_type']); $i++) { 151 212 $ductile_lists[$_POST['list_ctx'][$i]] = $_POST['list_type'][$i]; … … 209 270 } 210 271 211 $ductile_user = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_style');212 $ductile_user = @unserialize($ductile_user);213 if (!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();222 if (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 theme228 $ductile_stickers_images = files::scandir($img_path);229 if (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 sticker234 $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);242 if (!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);248 if (!is_array($ductile_counts)) {249 $ductile_counts = $ductile_counts_base;250 }251 252 272 // To be deleted when adminThemeConfigManaged behaviour will be implemented in admin/blog_themes.php : 253 273 echo '</form>'; … … 266 286 echo '<fieldset><legend>'.__('Stickers').'</legend>'; 267 287 268 echo '<table id="stickerslist">'.'<caption>'.__('Stickers (footer)').'</caption>'.288 echo '<table class="dragable">'.'<caption>'.__('Stickers (footer)').'</caption>'. 269 289 '<thead>'. 270 290 '<tr>'. 271 '<th scope="col">'. __('Position').'</th>'.291 '<th scope="col">'.'</th>'. 272 292 '<th scope="col">'.__('Image').'</th>'. 273 293 '<th scope="col">'.__('Label').'</th>'. … … 275 295 '</tr>'. 276 296 '</thead>'. 277 '<tbody>'; 278 $count = 1; 279 foreach ($ductile_stickers_full as $k => $v) { 297 '<tbody id="stickerslist">'; 298 $count = 0; 299 foreach ($ductile_stickers as $i => $v) { 300 $count++; 280 301 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>'. 302 '<tr class="line" id="l_'.$i.'">'. 303 '<td class="handle minimal">'.form::field(array('order['.$i.']'),2,3,$count,'position','',false). 304 form::hidden(array('dynorder[]','dynorder-'.$i),$i).'</td>'. 305 '<td>'.form::hidden(array('sticker_image[]'),$v['image']).'<img src="'.$img_url.$v['image'].'" /> '.'</td>'. 306 '<td scope="raw">'.form::field(array('sticker_label[]','dsl-'.$i),20,255,$v['label']).'</td>'. 307 '<td>'.form::field(array('sticker_url[]','dsu-'.$i),40,255,$v['url']).'</td>'. 286 308 '</tr>'; 287 309 } … … 323 345 324 346 echo '<input type="hidden" name="conf_tab" value="html">'; 325 echo '<p class="clear"> <input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>';347 echo '<p class="clear">'.form::hidden('ds_order','').'<input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>'; 326 348 echo '</form>'; 327 349 … … 434 456 echo '<form style="display:none">'; 435 457 458 // Need some more Js 459 $core->auth->user_prefs->addWorkspace('accessibility'); 460 $user_dm_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; 461 echo dcPage::jsToolMan(); 462 436 463 ?> 464 <?php if (!$user_dm_nodragdrop) : ?> 465 <script type="text/javascript"> 466 //<![CDATA[ 467 468 var dragsort = ToolMan.dragsort(); 469 $(function() { 470 dragsort.makeTableSortable($("#stickerslist").get(0), 471 dotclear.sortable.setHandle,dotclear.sortable.saveOrder); 472 }); 473 474 dotclear.sortable = { 475 setHandle: function(item) { 476 var handle = $(item).find('td.handle').get(0); 477 while (handle.firstChild) { 478 handle.removeChild(handle.firstChild); 479 } 480 481 item.toolManDragGroup.setHandle(handle); 482 handle.className = handle.className+' handler'; 483 }, 484 485 saveOrder: function(item) { 486 var group = item.toolManDragGroup; 487 var order = document.getElementById('ds_order'); 488 group.register('dragend', function() { 489 order.value = ''; 490 items = item.parentNode.getElementsByTagName('tr'); 491 492 for (var i=0; i<items.length; i++) { 493 order.value += items[i].id.substr(2)+','; 494 } 495 }); 496 } 497 }; 498 //]]> 499 </script> 500 <?php endif; ?>
Note: See TracChangeset
for help on using the changeset viewer.