Dotclear

Changeset 1490:60501ef579eb


Ignore:
Timestamp:
08/19/13 08:04:33 (10 years ago)
Author:
Dsls
Branch:
twig
Parents:
1489:f2398e7f3395 (diff), 1466:e67efe636ce1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Fusion avec default

Files:
4 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • admin/index.php

    r1422 r1490  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1313if (!empty($_GET['pf'])) { 
    1414     require dirname(__FILE__).'/../inc/load_plugin_file.php'; 
     15     exit; 
     16} 
     17if (!empty($_GET['tf'])) { 
     18     define('DC_CONTEXT_ADMIN',true); 
     19     require dirname(__FILE__).'/../inc/load_theme_file.php'; 
    1520     exit; 
    1621} 
     
    4348$plugins_install = $core->plugins->installModules(); 
    4449 
     50# Send plugins install messages to templates 
     51if (!empty($plugins_install['success'])) { 
     52     $_ctx->addMessagesList(__('Following plugins have been installed:'),$plugins_install['success']); 
     53} 
     54if (!empty($plugins_install['failure'])) { 
     55     $_ctx->addMessagesList(__('Following plugins have not been installed:'),$plugins_install['failure']); 
     56} 
     57 
     58# Send plugins errors messages to templates 
     59$_ctx->modules_errors = $core->auth->isSuperAdmin() ? $core->plugins->getErrors() : array(); 
     60 
     61# Send Dotclear updates notifications to tempaltes 
     62$_ctx->updater = array(); 
     63if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) { 
     64 
     65     $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 
     66     $new_v = $updater->check(DC_VERSION); 
     67     $version_info = $new_v ? $updater->getInfoURL() : ''; 
     68      
     69     if ($updater->getNotify() && $new_v) { 
     70          $_ctx->updater = array( 
     71               'new_version'  => $new_v, 
     72               'version_info' => $version_info 
     73          ); 
     74     } 
     75} 
     76 
    4577# Check dashboard module prefs 
    4678$ws = $core->auth->user_prefs->addWorkspace('dashboard'); 
     79 
     80# Doclinks prefs 
    4781if (!$core->auth->user_prefs->dashboard->prefExists('doclinks')) { 
    4882     if (!$core->auth->user_prefs->dashboard->prefExists('doclinks',true)) { 
     
    5185     $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean'); 
    5286} 
     87 
     88# Send doclinks to templates 
     89$_ctx->dashboard_doclinks = array(); 
     90if ($core->auth->user_prefs->dashboard->doclinks && !empty($__resources['doc'])) { 
     91     $_ctx->dashboard_doclinks = $__resources['doc']; 
     92} 
     93 
     94# Dcnews prefs 
    5395if (!$core->auth->user_prefs->dashboard->prefExists('dcnews')) { 
    5496     if (!$core->auth->user_prefs->dashboard->prefExists('dcnews',true)) { 
     
    5799     $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean'); 
    58100} 
     101 
     102# Send dcnews to templates 
     103$_ctx->dashboard_dcnews = array(); 
     104if ($core->auth->user_prefs->dashboard->dcnews && !empty($__resources['rss_news'])) { 
     105     try 
     106     { 
     107          $feed_reader = new feedReader; 
     108          $feed_reader->setCacheDir(DC_TPL_CACHE); 
     109          $feed_reader->setTimeout(2); 
     110          $feed_reader->setUserAgent('Dotclear - http://www.dotclear.org/'); 
     111          $feed = $feed_reader->parse($__resources['rss_news']); 
     112          if ($feed) { 
     113               $items = array(); 
     114               $i = 1; 
     115               foreach ($feed->items as $item) { 
     116                    $items[] = array( 
     117                         'title' => $item->title, 
     118                         'link' => isset($item->link) ? $item->link : '', 
     119                         'date' => dt::dt2str(__('%d %B %Y'),$item->pubdate,'Europe/Paris'), 
     120                         'content' => html::clean($item->content) 
     121                    ); 
     122                    $i++; 
     123                    if ($i > 3) { break; } 
     124               } 
     125               $_ctx->dashboard_dcnews = $items; 
     126          } 
     127     } 
     128     catch (Exception $e) {} 
     129} 
     130 
     131# Quick entry prefs 
    59132if (!$core->auth->user_prefs->dashboard->prefExists('quickentry')) { 
    60133     if (!$core->auth->user_prefs->dashboard->prefExists('quickentry',true)) { 
     
    62135     } 
    63136     $core->auth->user_prefs->dashboard->put('quickentry',true,'boolean'); 
     137} 
     138 
     139# Send quick entry to templates 
     140$_ctx->dashboard_quickentry = false; 
     141if ($core->auth->user_prefs->dashboard->quickentry &&$core->auth->check('usage,contentadmin',$core->blog->id)) 
     142{ 
     143     $categories_combo = array(' ' => ''); 
     144     try { 
     145          $categories = $core->blog->getCategories(array('post_type'=>'post')); 
     146          while ($categories->fetch()) { 
     147               $categories_combo[$categories->cat_id] =  
     148                    str_repeat('  ',$categories->level-1). 
     149                    ($categories->level-1 == 0 ? '' : '• '). 
     150                    html::escapeHTML($categories->cat_title); 
     151          } 
     152     } catch (Exception $e) { } 
     153      
     154     $form = new dcForm($core,array('quickentry','quick-entry'),'post.php'); 
     155     $form 
     156          ->addField( 
     157               new dcFieldText('post_title','', array( 
     158                    'size'         => 20, 
     159                    'required'     => true, 
     160                    'label'        => __('Title')))) 
     161          ->addField( 
     162               new dcFieldTextArea('post_content','', array( 
     163                    'required'     => true, 
     164                    'label'        => __("Content:")))) 
     165          ->addField( 
     166               new dcFieldCombo('cat_id','',$categories_combo,array( 
     167                    "label" => __('Category:')))) 
     168          ->addField( 
     169               new dcFieldSubmit('save',__('Save'),array( 
     170                    'action' => 'savePost'))) 
     171          ->addField( 
     172               new dcFieldHidden ('post_status',-2)) 
     173          ->addField( 
     174               new dcFieldHidden ('post_format',$core->auth->getOption('post_format'))) 
     175          ->addField( 
     176               new dcFieldHidden ('post_excerpt','')) 
     177          ->addField( 
     178               new dcFieldHidden ('post_lang',$core->auth->getInfo('user_lang'))) 
     179          ->addField( 
     180               new dcFieldHidden ('post_notes','')) 
     181     ; 
     182     if ($core->auth->check('publish',$core->blog->id)) { 
     183          $form->addField( 
     184               new dcFieldHidden ('save-publish',__('Save and publish'))); 
     185     } 
     186      
     187     $_ctx->dashboard_quickentry = true; 
    64188} 
    65189 
     
    118242} 
    119243 
    120 # Latest news for dashboard 
     244# Send dashboard icons to templates 
     245$icons = array(); 
     246foreach ($__dashboard_icons as $i) { 
     247     $icons[] = array( 
     248          'title'   => $i[0], 
     249          'url'     => $i[1], 
     250          'img'     => dc_admin_icon_url($i[2]) 
     251     ); 
     252} 
     253$_ctx->dashboard_icons = $icons; 
     254 
     255# Dashboard items 
    121256$__dashboard_items = new ArrayObject(array(new ArrayObject,new ArrayObject)); 
    122  
    123 $dashboardItem = 0; 
    124  
    125 if ($core->auth->user_prefs->dashboard->dcnews) { 
    126      try 
    127      { 
    128           if (empty($__resources['rss_news'])) { 
    129                throw new Exception(); 
    130           } 
    131       
    132           $feed_reader = new feedReader; 
    133           $feed_reader->setCacheDir(DC_TPL_CACHE); 
    134           $feed_reader->setTimeout(2); 
    135           $feed_reader->setUserAgent('Dotclear - http://www.dotclear.org/'); 
    136           $feed = $feed_reader->parse($__resources['rss_news']); 
    137           if ($feed) 
    138           { 
    139                $latest_news = '<h3>'.__('Latest news').'</h3><dl id="news">'; 
    140                $i = 1; 
    141                foreach ($feed->items as $item) 
    142                { 
    143                     $dt = isset($item->link) ? '<a href="'.$item->link.'" title="'.$item->title.' '.__('(external link)').'">'. 
    144                          $item->title.'</a>' : $item->title; 
    145                 
    146                     if ($i < 3) { 
    147                          $latest_news .= 
    148                          '<dt>'.$dt.'</dt>'. 
    149                          '<dd><p><strong>'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'</strong> '. 
    150                          '<em>'.text::cutString(html::clean($item->content),120).'...</em></p></dd>'; 
    151                     } else { 
    152                          $latest_news .= 
    153                          '<dt>'.$dt.'</dt>'. 
    154                          '<dd>'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'</dd>'; 
    155                     } 
    156                     $i++; 
    157                     if ($i > 3) { break; } 
    158                } 
    159                $latest_news .= '</dl>'; 
    160                $__dashboard_items[$dashboardItem][] = $latest_news; 
    161                $dashboardItem++; 
    162           } 
    163      } 
    164      catch (Exception $e) {} 
    165 } 
    166  
    167 # Documentation links 
    168 if ($core->auth->user_prefs->dashboard->doclinks) { 
    169      if (!empty($__resources['doc'])) 
    170      { 
    171           $doc_links = '<h3>'.__('Documentation and support').'</h3><ul>'; 
    172       
    173           foreach ($__resources['doc'] as $k => $v) { 
    174                $doc_links .= '<li><a href="'.$v.'" title="'.$k.' '.__('(external link)').'">'.$k.'</a></li>'; 
    175           } 
    176       
    177           $doc_links .= '</ul>'; 
    178           $__dashboard_items[$dashboardItem][] = $doc_links; 
    179           $dashboardItem++; 
    180      } 
    181 } 
    182  
    183257$core->callBehavior('adminDashboardItems', $core, $__dashboard_items); 
    184258 
     259# Send dashboard items to templates 
     260$items = array(); 
     261foreach ($__dashboard_items as $i) {     
     262     if ($i->count() > 0) { 
     263          foreach ($i as $v) { 
     264               $items[] = $v; 
     265          } 
     266     } 
     267} 
     268$_ctx->dashboard_items = $items; 
     269 
    185270# Dashboard content 
    186 $dashboardContents = ''; 
    187271$__dashboard_contents = new ArrayObject(array(new ArrayObject,new ArrayObject)); 
    188272$core->callBehavior('adminDashboardContents', $core, $__dashboard_contents); 
    189273 
    190 /* DISPLAY 
    191 -------------------------------------------------------- */ 
    192 dcPage::open(__('Dashboard'), 
    193      dcPage::jsToolBar(). 
    194      dcPage::jsLoad('js/_index.js'). 
    195      # --BEHAVIOR-- adminDashboardHeaders 
    196      $core->callBehavior('adminDashboardHeaders'), 
    197      dcPage::breadcrumb( 
    198           array( 
    199           '<span class="page-title">'.__('Dashboard').' : '.html::escapeHTML($core->blog->name).'</span>' => '' 
    200           ), 
    201           false) 
    202 ); 
    203  
    204 # Dotclear updates notifications 
    205 if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) 
    206 { 
    207      $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 
    208      $new_v = $updater->check(DC_VERSION); 
    209      $version_info = $new_v ? $updater->getInfoURL() : ''; 
    210  
    211      if ($updater->getNotify() && $new_v) { 
    212           $message = 
    213           '<div><p>'.sprintf(__('Dotclear %s is available!'),$new_v).'</p> '. 
    214           '<ul><li><strong><a href="update.php">'.sprintf(__('Upgrade now'),$new_v).'</a></strong>'. 
    215           '</li><li><a href="update.php?hide_msg=1">'.__('Remind me later').'</a>'. 
    216           ($version_info ? ' </li><li><a href="'.$version_info.'">'.__('information about this version').'</a>' : ''). 
    217           '</li></ul></div>'; 
    218           dcPage::message($message,false,true); 
    219      } 
    220 } 
    221  
    222 if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->blog_count > 1) { 
    223      echo 
    224      '<p><a href="index.php?default_blog=1" class="button">'.__('Make this blog my default blog').'</a></p>'; 
    225 } 
    226  
     274# Send dashboard contents to templates 
     275$contents = array(); 
     276foreach ($__dashboard_contents as $i) {  
     277     if ($i->count() > 0) { 
     278          foreach ($i as $v) { 
     279               $contents[] = $v; 
     280          } 
     281     } 
     282} 
     283$_ctx->dashboard_contents = $contents; 
     284 
     285# Blog status message 
    227286if ($core->blog->status == 0) { 
    228      echo '<p class="static-msg">'.__('This blog is offline').'</p>'; 
     287     $_ctx->addMessageStatic(__('This blog is offline')); 
    229288} elseif ($core->blog->status == -1) { 
    230      echo '<p class="static-msg">'.__('This blog is removed').'</p>'; 
    231 } 
    232  
     289     $_ctx->addMessageStatic(__('This blog is removed')); 
     290} 
     291 
     292# Config errors messages 
    233293if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) { 
    234      echo 
    235      '<p class="static-msg">'. 
    236      sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL'). 
    237      ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 
    238      '</p>'; 
    239 } 
    240  
     294     $_ctx->addMessageStatic( 
     295          sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL').' '. 
     296          __('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.') 
     297     ); 
     298} 
    241299if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) { 
    242      echo 
    243      '<p class="static-msg">'. 
    244      sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM'). 
    245      ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 
    246      '</p>'; 
    247 } 
    248  
    249 # Plugins install messages 
    250 if (!empty($plugins_install['success'])) 
    251 { 
    252      echo '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; 
    253      foreach ($plugins_install['success'] as $k => $v) { 
    254           echo '<li>'.$k.'</li>'; 
    255      } 
    256      echo '</ul></div>'; 
    257 } 
    258 if (!empty($plugins_install['failure'])) 
    259 { 
    260      echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 
    261      foreach ($plugins_install['failure'] as $k => $v) { 
    262           echo '<li>'.$k.' ('.$v.')</li>'; 
    263      } 
    264      echo '</ul></div>'; 
    265 } 
    266  
    267 # Dashboard columns (processed first, as we need to know the result before displaying the icons.) 
    268 $dashboardItems = ''; 
    269  
    270 # Errors modules notifications 
    271 if ($core->auth->isSuperAdmin()) 
    272 { 
    273      $list = array(); 
    274      foreach ($core->plugins->getErrors() as $k => $error) { 
    275           $list[] = '<li>'.$error.'</li>'; 
    276      } 
    277       
    278      if (count($list) > 0) { 
    279           $dashboardItems .= 
    280           '<div id="module-errors" class="error"><p>'.__('Some plugins are installed twice:').'</p> '. 
    281           '<ul>'.implode("\n",$list).'</ul></div>'; 
    282      } 
    283       
    284 } 
    285  
    286 foreach ($__dashboard_items as $i) 
    287 {     
    288      if ($i->count() > 0) 
    289      { 
    290           $dashboardItems .= '<div class="db-item">'; 
    291           foreach ($i as $v) { 
    292                $dashboardItems .= $v; 
    293           } 
    294           $dashboardItems .= '</div>'; 
    295      } 
    296 } 
    297  
    298 # Dashboard icons 
    299 echo '<div id="dashboard-main"'.($dashboardItems ? '' : ' class="fullwidth"').'><div id="icons">'; 
    300 foreach ($__dashboard_icons as $i) 
    301 { 
    302      echo 
    303      '<p><a href="'.$i[1].'"><img src="'.dc_admin_icon_url($i[2]).'" alt="" />'. 
    304      '<br /><span>'.$i[0].'</span></a></p>'; 
    305 } 
    306 echo '</div>'; 
    307  
    308 if ($core->auth->user_prefs->dashboard->quickentry) { 
    309      if ($core->auth->check('usage,contentadmin',$core->blog->id)) 
    310      { 
    311           $categories_combo = array('&nbsp;' => ''); 
    312           try { 
    313                $categories = $core->blog->getCategories(array('post_type'=>'post')); 
    314                while ($categories->fetch()) { 
    315                     $categories_combo[] = new formSelectOption( 
    316                          str_repeat('&nbsp;&nbsp;',$categories->level-1). 
    317                          ($categories->level-1 == 0 ? '' : '&bull; ').html::escapeHTML($categories->cat_title), 
    318                          $categories->cat_id 
    319                     ); 
    320                } 
    321           } catch (Exception $e) { } 
    322       
    323           echo 
    324           '<div id="quick">'. 
    325           '<h3>'.__('Quick entry').'</h3>'. 
    326           '<form id="quick-entry" action="post.php" method="post">'. 
    327           '<fieldset><legend>'.__('New entry').'</legend>'. 
    328           '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 
    329           form::field('post_title',20,255,'','maximal'). 
    330           '</p>'. 
    331           '<p class="area"><label class="required" '. 
    332           'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 
    333           form::textarea('post_content',50,7). 
    334           '</p>'. 
    335           '<p><label for="cat_id" class="classic">'.__('Category:').'</label> '. 
    336           form::combo('cat_id',$categories_combo).'</p>'. 
    337           '<p><input type="submit" value="'.__('Save').'" name="save" /> '. 
    338           ($core->auth->check('publish',$core->blog->id) 
    339                ? '<input type="hidden" value="'.__('Save and publish').'" name="save-publish" />' 
    340                : ''). 
    341           $core->formNonce(). 
    342           form::hidden('post_status',-2). 
    343           form::hidden('post_format',$core->auth->getOption('post_format')). 
    344           form::hidden('post_excerpt',''). 
    345           form::hidden('post_lang',$core->auth->getInfo('user_lang')). 
    346           form::hidden('post_notes',''). 
    347           '</p>'. 
    348           '</fieldset>'. 
    349           '</form>'. 
    350           '</div>'; 
    351      } 
    352 } 
    353  
    354 foreach ($__dashboard_contents as $i) 
    355 {     
    356      if ($i->count() > 0) 
    357      { 
    358           $dashboardContents .= '<div>'; 
    359           foreach ($i as $v) { 
    360                $dashboardContents .= $v; 
    361           } 
    362           $dashboardContents .= '</div>'; 
    363      } 
    364 } 
    365 echo ($dashboardContents ? '<div id="dashboard-contents">'.$dashboardContents.'</div>' : ''); 
    366  
    367 echo '</div>'; 
    368  
    369 echo ($dashboardItems ? '<div id="dashboard-items">'.$dashboardItems.'</div>' : ''); 
    370  
    371 dcPage::close(); 
     300     $_ctx->addMessageStatic( 
     301          sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM').' '. 
     302          __('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.') 
     303     ); 
     304} 
     305 
     306$_ctx->setBreadCrumb(__('Dashboard').' : '.html::escapeHTML($core->blog->name), false); 
     307$core->tpl->display('index.html.twig'); 
    372308?> 
  • admin/js/_post.js

    r1414 r1490  
    122122               hide: $('#post_password').val() == '' 
    123123          }); 
    124            
     124          $('#post_status').parent().toggleWithLegend($('#post_status'),{ 
     125               cookie: 'dcx_post_status' 
     126          }); 
     127          $('#post_dt').parent().toggleWithLegend($('#post_dt').parent().children().not('label'),{ 
     128               cookie: 'dcx_post_dt' 
     129          }); 
     130          $('#post_format').parent().toggleWithLegend($('#post_format').parent().children().not('label').add($('#post_format').parents('p').next()),{ 
     131               cookie: 'dcx_post_format' 
     132          }); 
     133          $('#cat_id').parent().toggleWithLegend($('#cat_id'),{ 
     134               cookie: 'cat_id' 
     135          }); 
     136          $('#post_url').parent().toggleWithLegend($('#post_url').parent().children().not('label'),{ 
     137               cookie: 'post_url' 
     138          }); 
    125139          // We load toolbar on excerpt only when it's ready 
    126140          $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ 
    127141               fn: function() { excerptTb.switchMode(formatField.value); }, 
    128142               cookie: 'dcx_post_excerpt', 
    129                hide: $('#post_excerpt').val() == '', 
    130                legend_click: true 
     143               hide: $('#post_excerpt').val() == '' 
    131144          }); 
    132145           
     
    150163          var a = document.createElement('a'); 
    151164          a.href = '#'; 
     165          a.className = 'button'; 
    152166          $(a).click(function() { 
    153167               var params = { 
  • admin/plugin.php

    r1358 r1490  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1515dcPage::check('usage,contentadmin'); 
    1616 
     17$has_content = false; 
    1718$p_file = ''; 
    1819$p = !empty($_REQUEST['p']) ? $_REQUEST['p'] : null; 
    19 $popup = (integer) !empty($_REQUEST['popup']); 
    20  
    21 if ($popup) { 
    22      $open_f = array('dcPage','openPopup'); 
    23      $close_f = array('dcPage','closePopup'); 
    24 } else { 
    25      $open_f = array('dcPage','open'); 
    26      $close_f = array('dcPage','close'); 
    27 } 
     20$popup = $_ctx->popup = (integer) !empty($_REQUEST['popup']); 
    2821 
    2922if ($core->plugins->moduleExists($p)) { 
    3023     $p_file = $core->plugins->moduleRoot($p).'/index.php'; 
    3124} 
     25if (file_exists($p_file)) { 
    3226 
    33 if (file_exists($p_file)) 
    34 { 
    35      # Loading plugin 
     27//* Keep this for old style plugins using dcPage 
     28     if ($popup) { 
     29          $open_f = array('dcPage','openPopup'); 
     30          $close_f = array('dcPage','closePopup'); 
     31     } else { 
     32          $open_f = array('dcPage','open'); 
     33          $close_f = array('dcPage','close'); 
     34     } 
     35      
    3636     $p_info = $core->plugins->getModules($p); 
    37       
    3837     $p_url = 'plugin.php?p='.$p; 
    39       
    40      $p_title = 'no content - plugin'; 
    41      $p_head = ''; 
    42      $p_content = '<p>'.__('No content found on this plugin.').'</p>'; 
    43       
     38     $p_title = $p_head = $p_content = ''; 
     39//*/  
     40     # Get page content 
    4441     ob_start(); 
    4542     include $p_file; 
    4643     $res = ob_get_contents(); 
    4744     ob_end_clean(); 
    48       
    49      if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { 
    50           if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { 
    51                $p_title = $mt[1]; 
    52           } 
     45 
     46     # Check context and display 
     47     if ($_ctx->hasPageTitle() && !empty($res)) { 
     48          $has_content = true; 
     49          echo $res; 
     50     } 
     51//* Keep this for old style plugins using dcPage 
     52     elseif (!$_ctx->hasPageTitle()) { 
    5353           
    54           if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { 
    55                foreach ($ms[1] as $v) { 
    56                     $p_head .= $v."\n"; 
     54          if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { 
     55               if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { 
     56                    $p_title = $mt[1]; 
     57               } 
     58                
     59               if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { 
     60                    foreach ($ms[1] as $v) { 
     61                         $p_head .= $v."\n"; 
     62                    } 
     63               } 
     64                
     65               if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { 
     66                    foreach ($ms[1] as $v) { 
     67                         $p_head .= $v."\n"; 
     68                    } 
     69               } 
     70                
     71               if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { 
     72                    foreach ($ms[1] as $v) { 
     73                         $p_head .= $v."\n"; 
     74                    } 
    5775               } 
    5876          } 
    5977           
    60           if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { 
    61                foreach ($ms[1] as $v) { 
    62                     $p_head .= $v."\n"; 
    63                } 
    64           } 
    65            
    66           if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { 
    67                foreach ($ms[1] as $v) { 
    68                     $p_head .= $v."\n"; 
    69                } 
     78          if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { 
     79               $p_content = $m[1]; 
     80                
     81               call_user_func($open_f,$p_title,$p_head); 
     82               echo $p_content; 
     83               call_user_func($close_f); 
     84                
     85               $has_content = true; 
    7086          } 
    7187     } 
    72       
    73      if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { 
    74           $p_content = $m[1]; 
    75      } 
    76       
    77      call_user_func($open_f,$p_title,$p_head); 
    78      echo $p_content; 
    79      call_user_func($close_f); 
     88//*/ 
    8089} 
    81 else 
    82 { 
    83      call_user_func($open_f,__('Plugin not found'),'', 
    84           dcPage::breadcrumb( 
    85                array( 
    86                     __('System') => '', 
    87                     '<span class="page-title">'.__('Plugin not found').'</span>' => '' 
    88                )) 
    89      ); 
    90       
    91      echo '<p>'.__('The plugin you reached does not exist or does not have an admin page.').'</p>'; 
    92       
    93      call_user_func($close_f); 
     90# No plugin or content found 
     91if (!$has_content) { 
     92     $_ctx->setBreadcrumb(__('Plugin not found')); 
     93     $_ctx->addError(__('The plugin you reached does not exist or does not have an admin page.')); 
     94     $core->tpl->display('plugin.html.twig'); 
    9495} 
    9596?> 
  • admin/post.php

    r1460 r1490  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1515dcPage::check('usage,contentadmin'); 
    1616 
    17 $post_id = ''; 
    18 $cat_id = ''; 
    19 $post_dt = ''; 
    20 $post_format = $core->auth->getOption('post_format'); 
    21 $post_password = ''; 
    22 $post_url = ''; 
    23 $post_lang = $core->auth->getInfo('user_lang'); 
    24 $post_title = ''; 
    25 $post_excerpt = ''; 
    26 $post_excerpt_xhtml = ''; 
    27 $post_content = ''; 
    28 $post_content_xhtml = ''; 
    29 $post_notes = ''; 
    30 $post_status = $core->auth->getInfo('user_post_status'); 
    31 $post_selected = false; 
    32 $post_open_comment = $core->blog->settings->system->allow_comments; 
    33 $post_open_tb = $core->blog->settings->system->allow_trackbacks; 
     17class PostActions  
     18{ 
     19     public static function savePost($form) { 
     20          global $_ctx, $core; 
     21          try { 
     22               $form->check($_ctx); 
     23               $_ctx->setAlert('save'); 
     24               $form->cat_id = (integer) $form->cat_id; 
     25      
     26               if (!empty($form->post_dt)) { 
     27                    try 
     28                    { 
     29                         $post_dt = strtotime($form->post_dt); 
     30                         if ($post_dt == false || $post_dt == -1) { 
     31                              $bad_dt = true; 
     32                              throw new Exception(__('Invalid publication date')); 
     33                         } 
     34                         $form->post_dt = date('Y-m-d H:i',$post_dt); 
     35                    } 
     36                    catch (Exception $e) 
     37                    { 
     38                         $core->error->add($e->getMessage()); 
     39                    } 
     40               } 
     41               $post_excerpt = $form->post_excerpt; 
     42               $post_content = $form->post_content; 
     43               $post_excerpt_xhtml = ''; 
     44               $post_content_xhtml = ''; 
     45               $core->blog->setPostContent( 
     46                    $form->id,$form->post_format,$form->post_lang, 
     47                    $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml 
     48               ); 
     49               $form->post_excerpt = $post_excerpt; 
     50               $form->post_content = $post_content; 
     51               $form->post_excerpt_xhtml = $post_excerpt_xhtml; 
     52               $form->post_content_xhtml = $post_content_xhtml; 
     53                
     54               $cur = $core->con->openCursor($core->prefix.'post'); 
     55      
     56               $cur->post_title = $form->post_title; 
     57               $cur->cat_id = $form->cat_id ? $form->cat_id : null; 
     58               $cur->post_dt = $form->post_dt ? date('Y-m-d H:i:00',strtotime($form->post_dt)) : ''; 
     59               $cur->post_format = $form->post_format; 
     60               $cur->post_password = $form->post_password; 
     61               $cur->post_lang = $form->post_lang; 
     62               $cur->post_title = $form->post_title; 
     63               $cur->post_excerpt = $form->post_excerpt; 
     64               $cur->post_excerpt_xhtml = $form->post_excerpt_xhtml; 
     65               $cur->post_content = $form->post_content; 
     66               $cur->post_content_xhtml = $form->post_content_xhtml; 
     67               $cur->post_notes = $form->post_notes; 
     68               $cur->post_status = $form->post_status; 
     69               $cur->post_selected = (integer) $form->post_selected; 
     70               $cur->post_open_comment = (integer) $form->post_open_comment; 
     71               $cur->post_open_tb = (integer) $form->post_open_tb; 
     72      
     73               if (!empty($form->post_url)) { 
     74                    $cur->post_url = $form->post_url; 
     75               } 
     76      
     77               # Update post 
     78               if ($form->id) 
     79               { 
     80                    # --BEHAVIOR-- adminBeforePostUpdate 
     81                    $core->callBehavior('adminBeforePostUpdate',$cur,$form->id); 
     82                     
     83                    $core->blog->updPost($form->id,$cur); 
     84                     
     85                    # --BEHAVIOR-- adminAfterPostUpdate 
     86                    $core->callBehavior('adminAfterPostUpdate',$cur,$form->id); 
     87                     
     88                    http::redirect('post.php?id='.$form->id.'&upd=1'); 
     89               } 
     90               else 
     91               { 
     92                    $cur->user_id = $core->auth->userID(); 
     93                                        # --BEHAVIOR-- adminBeforePostCreate 
     94                    $core->callBehavior('adminBeforePostCreate',$cur); 
     95                     
     96                    $return_id = $core->blog->addPost($cur); 
     97                     
     98                    # --BEHAVIOR-- adminAfterPostCreate 
     99                    $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 
     100                     
     101                    http::redirect('post.php?id='.$return_id.'&crea=1'); 
     102               } 
     103 
     104     } catch (Exception $e) { 
     105          $ctx->setError($e->getMessage()); 
     106     } 
     107} 
     108     function deletePost($form) { 
     109          echo $form->id->getValue(); exit; 
     110     } 
     111} 
    34112 
    35113$page_title = __('New entry'); 
    36  
     114$post_id=''; 
    37115$can_view_page = true; 
    38116$can_edit_post = $core->auth->check('usage,contentadmin',$core->blog->id); 
     
    47125# If user can't publish 
    48126if (!$can_publish) { 
    49      $post_status = -2; 
     127     $form->post_status = -2; 
    50128} 
    51129 
     
    55133     $categories = $core->blog->getCategories(array('post_type'=>'post')); 
    56134     while ($categories->fetch()) { 
    57           $categories_combo[] = new formSelectOption( 
    58                str_repeat('&nbsp;&nbsp;',$categories->level-1).($categories->level-1 == 0 ? '' : '&bull; ').html::escapeHTML($categories->cat_title), 
    59                $categories->cat_id 
    60           ); 
     135          $categories_combo[$categories->cat_id] =  
     136               str_repeat('&nbsp;&nbsp;',$categories->level-1). 
     137               ($categories->level-1 == 0 ? '' : '&bull; '). 
     138               html::escapeHTML($categories->cat_title); 
    61139     } 
    62140} catch (Exception $e) { } 
     
    64142# Status combo 
    65143foreach ($core->blog->getAllPostStatus() as $k => $v) { 
    66      $status_combo[$v] = (string) $k; 
    67 } 
    68 $img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     144     $status_combo[$k] = $v; 
     145} 
    69146 
    70147# Formaters combo 
     
    76153$rs = $core->blog->getLangs(array('order'=>'asc')); 
    77154$all_langs = l10n::getISOcodes(0,1); 
    78 $lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1,1)); 
     155$lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(0,1)); 
    79156while ($rs->fetch()) { 
    80157     if (isset($all_langs[$rs->post_lang])) { 
    81           $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang; 
    82           unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]); 
     158          $lang_combo[__('Most used')][$rs->post_lang] = $all_langs[$rs->post_lang]; 
     159          unset($lang_combo[__('Available')][$rs->post_lang]); 
    83160     } else { 
    84           $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang; 
     161          $lang_combo[__('Most used')][$rs->post_lang] = $all_langs[$rs->post_lang]; 
    85162     } 
    86163} 
     
    88165unset($rs); 
    89166 
    90 # Validation flag 
    91 $bad_dt = false; 
    92  
     167$form = new dcForm($core,'post','post.php'); 
     168$form 
     169     ->addField( 
     170          new dcFieldText('post_title','', array( 
     171               'maxlength'         => 255, 
     172               'required'     => true, 
     173               'label'        => __('Title')))) 
     174     ->addField( 
     175          new dcFieldTextArea('post_excerpt','', array( 
     176               'cols'         => 50, 
     177               'rows'         => 5, 
     178               'label'        => __("Excerpt:")))) 
     179     ->addField( 
     180          new dcFieldTextArea('post_content','', array( 
     181               'required'     => true, 
     182               'label'        => __("Content:")))) 
     183     ->addField( 
     184          new dcFieldTextArea('post_notes','', array( 
     185               'label'        => __("Notes")))) 
     186     ->addField( 
     187          new dcFieldSubmit('save',__('Save'),array( 
     188               'action' => array('PostActions','savePost')))) 
     189     ->addField( 
     190          new dcFieldSubmit('delete',__('Delete'),array( 
     191               'action' => 'deletePost'))) 
     192     ->addField( 
     193          new dcFieldCombo('post_status',$core->auth->getInfo('user_post_status'),$status_combo,array( 
     194               'disabled' => !$can_publish, 
     195               'label' => __('Entry status:')))) 
     196     ->addField( 
     197          new dcFieldCombo('cat_id','',$categories_combo,array( 
     198               "label" => __('Category:')))) 
     199     ->addField( 
     200          new dcFieldText('post_dt','',array( 
     201               "label" => __('Published on:')))) 
     202     ->addField( 
     203          new dcFieldCombo('post_format',$core->auth->getOption('post_format'),$formaters_combo,array( 
     204               "label" => __('Text formating:')))) 
     205     ->addField( 
     206          new dcFieldCheckbox ('post_open_comment',$core->blog->settings->system->allow_comments,array( 
     207               "label" => __('Accept comments')))) 
     208     ->addField( 
     209          new dcFieldCheckbox ('post_open_tb',$core->blog->settings->system->allow_trackbacks,array( 
     210               "label" => __('Accept trackbacks')))) 
     211     ->addField( 
     212          new dcFieldCheckbox ('post_selected',array(1=>false),array( 
     213               "label" => __('Selected entry')))) 
     214     ->addField( 
     215          new dcFieldCombo ('post_lang',$core->auth->getInfo('user_lang'),$lang_combo, array( 
     216               "label" => __('Entry lang:')))) 
     217     ->addField( 
     218          new dcFieldText('post_password','',array( 
     219               "maxlength" => 32, 
     220               "label" => __('Entry password:')))) 
     221     ->addField( 
     222          new dcFieldText('post_url','',array( 
     223               "maxlength" => 255, 
     224               "label" => __('Basename:')))) 
     225     ->addField( 
     226          new dcFieldHidden ('id','')) 
     227; 
    93228# Get entry informations 
    94229if (!empty($_REQUEST['id'])) 
    95230{ 
    96      $page_title = __('Edit entry'); 
    97       
    98231     $params['post_id'] = $_REQUEST['id']; 
    99232      
     
    107240     else 
    108241     { 
    109           $post_id = $post->post_id; 
    110           $cat_id = $post->cat_id; 
    111           $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 
    112           $post_format = $post->post_format; 
    113           $post_password = $post->post_password; 
    114           $post_url = $post->post_url; 
    115           $post_lang = $post->post_lang; 
    116           $post_title = $post->post_title; 
    117           $post_excerpt = $post->post_excerpt; 
    118           $post_excerpt_xhtml = $post->post_excerpt_xhtml; 
    119           $post_content = $post->post_content; 
    120           $post_content_xhtml = $post->post_content_xhtml; 
    121           $post_notes = $post->post_notes; 
    122           $post_status = $post->post_status; 
    123           $post_selected = (boolean) $post->post_selected; 
    124           $post_open_comment = (boolean) $post->post_open_comment; 
    125           $post_open_tb = (boolean) $post->post_open_tb; 
     242          $form->id = $post_id = $post->post_id; 
     243          $form->cat_id = $post->cat_id; 
     244          $form->post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 
     245          $form->post_format = $post->post_format; 
     246          $form->post_password = $post->post_password; 
     247          $form->post_url = $post->post_url; 
     248          $form->post_lang = $post->post_lang; 
     249          $form->post_title = $post->post_title; 
     250          $form->post_excerpt = $post->post_excerpt; 
     251          $form->post_excerpt_xhtml = $post->post_excerpt_xhtml; 
     252          $form->post_content = $post->post_content; 
     253          $form->post_content_xhtml = $post->post_content_xhtml; 
     254          $form->post_notes = $post->post_notes; 
     255          $form->post_status = $post->post_status; 
     256          $form->post_selected = (boolean) $post->post_selected; 
     257          $form->post_open_comment = (boolean) $post->post_open_comment; 
     258          $form->post_open_tb = (boolean) $post->post_open_tb; 
     259          $form->can_edit_post = $post->isEditable(); 
     260          $form->can_delete= $post->isDeletable(); 
     261          $page_title = __('Edit entry'); 
     262 
     263     } 
     264} 
     265if ($post_id) { 
     266     $_ctx->post_id = $post->post_id; 
     267 
     268     $_ctx->preview_url = 
     269          $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 
     270          http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 
     271          '/'.$post->post_url); 
    126272           
    127           $can_edit_post = $post->isEditable(); 
    128           $can_delete= $post->isDeletable(); 
    129            
    130           $next_rs = $core->blog->getNextPost($post,1); 
    131           $prev_rs = $core->blog->getNextPost($post,-1); 
    132            
    133           if ($next_rs !== null) { 
    134                $next_link = sprintf($post_link,$next_rs->post_id, 
    135                     html::escapeHTML($next_rs->post_title),__('Next entry').'&nbsp;&#187;'); 
    136                $next_headlink = sprintf($post_headlink,'next', 
    137                     html::escapeHTML($next_rs->post_title),$next_rs->post_id); 
    138           } 
    139            
    140           if ($prev_rs !== null) { 
    141                $prev_link = sprintf($post_link,$prev_rs->post_id, 
    142                     html::escapeHTML($prev_rs->post_title),'&#171;&nbsp;'.__('Previous entry')); 
    143                $prev_headlink = sprintf($post_headlink,'previous', 
    144                     html::escapeHTML($prev_rs->post_title),$prev_rs->post_id); 
    145           } 
    146            
    147           try { 
    148                $core->media = new dcMedia($core); 
    149           } catch (Exception $e) {} 
    150      } 
    151 } 
    152  
    153 # Format excerpt and content 
    154 if (!empty($_POST) && $can_edit_post) 
    155 { 
    156      $post_format = $_POST['post_format']; 
    157      $post_excerpt = $_POST['post_excerpt']; 
    158      $post_content = $_POST['post_content']; 
    159       
    160      $post_title = $_POST['post_title']; 
    161       
    162      $cat_id = (integer) $_POST['cat_id']; 
    163       
    164      if (isset($_POST['post_status'])) { 
    165           $post_status = (integer) $_POST['post_status']; 
    166      } 
    167       
    168      if (empty($_POST['post_dt'])) { 
    169           $post_dt = ''; 
    170      } else { 
    171           try 
    172           { 
    173                $post_dt = strtotime($_POST['post_dt']); 
    174                if ($post_dt == false || $post_dt == -1) { 
    175                     $bad_dt = true; 
    176                     throw new Exception(__('Invalid publication date')); 
    177                } 
    178                $post_dt = date('Y-m-d H:i',$post_dt); 
    179           } 
    180           catch (Exception $e) 
    181           { 
    182                $core->error->add($e->getMessage()); 
    183           } 
    184      } 
    185       
    186      $post_open_comment = !empty($_POST['post_open_comment']); 
    187      $post_open_tb = !empty($_POST['post_open_tb']); 
    188      $post_selected = !empty($_POST['post_selected']); 
    189      $post_lang = $_POST['post_lang']; 
    190      $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; 
    191       
    192      $post_notes = $_POST['post_notes']; 
    193       
    194      if (isset($_POST['post_url'])) { 
    195           $post_url = $_POST['post_url']; 
    196      } 
    197       
    198      $core->blog->setPostContent( 
    199           $post_id,$post_format,$post_lang, 
    200           $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml 
    201      ); 
    202 } 
    203  
    204 # Delete post 
    205 if (!empty($_POST['delete']) && $can_delete) 
    206 { 
    207      try { 
    208           # --BEHAVIOR-- adminBeforePostDelete 
    209           $core->callBehavior('adminBeforePostDelete',$post_id); 
    210           $core->blog->delPost($post_id); 
    211           http::redirect('posts.php'); 
    212      } catch (Exception $e) { 
    213           $core->error->add($e->getMessage()); 
    214      } 
    215 } 
    216  
    217 # Create or update post 
    218 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) 
    219 { 
    220      $cur = $core->con->openCursor($core->prefix.'post'); 
    221       
    222      $cur->post_title = $post_title; 
    223      $cur->cat_id = ($cat_id ? $cat_id : null); 
    224      $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; 
    225      $cur->post_format = $post_format; 
    226      $cur->post_password = $post_password; 
    227      $cur->post_lang = $post_lang; 
    228      $cur->post_title = $post_title; 
    229      $cur->post_excerpt = $post_excerpt; 
    230      $cur->post_excerpt_xhtml = $post_excerpt_xhtml; 
    231      $cur->post_content = $post_content; 
    232      $cur->post_content_xhtml = $post_content_xhtml; 
    233      $cur->post_notes = $post_notes; 
    234      $cur->post_status = $post_status; 
    235      $cur->post_selected = (integer) $post_selected; 
    236      $cur->post_open_comment = (integer) $post_open_comment; 
    237      $cur->post_open_tb = (integer) $post_open_tb; 
    238       
    239      if (isset($_POST['post_url'])) { 
    240           $cur->post_url = $post_url; 
    241      } 
    242       
    243      # Update post 
    244      if ($post_id) 
    245      { 
    246           try 
    247           { 
    248                # --BEHAVIOR-- adminBeforePostUpdate 
    249                $core->callBehavior('adminBeforePostUpdate',$cur,$post_id); 
    250                 
    251                $core->blog->updPost($post_id,$cur); 
    252                 
    253                # --BEHAVIOR-- adminAfterPostUpdate 
    254                $core->callBehavior('adminAfterPostUpdate',$cur,$post_id); 
    255                 
    256                http::redirect('post.php?id='.$post_id.'&upd=1'); 
    257           } 
    258           catch (Exception $e) 
    259           { 
    260                $core->error->add($e->getMessage()); 
    261           } 
    262      } 
    263      else 
    264      { 
    265           $cur->user_id = $core->auth->userID(); 
    266            
    267           try 
    268           { 
    269                # --BEHAVIOR-- adminBeforePostCreate 
    270                $core->callBehavior('adminBeforePostCreate',$cur); 
    271                 
    272                $return_id = $core->blog->addPost($cur); 
    273                 
    274                # --BEHAVIOR-- adminAfterPostCreate 
    275                $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 
    276                 
    277                http::redirect('post.php?id='.$return_id.'&crea=1'); 
    278           } 
    279           catch (Exception $e) 
    280           { 
    281                $core->error->add($e->getMessage()); 
    282           } 
    283      } 
    284 } 
     273      
     274     $form_comment = new dcForm($core,'add-comment','post.php'); 
     275     $form_comment 
     276          ->addField( 
     277               new dcFieldText('comment_author','', array( 
     278                    'maxlength'         => 255, 
     279                    'required'     => true, 
     280                    'label'        => __('Name:')))) 
     281          ->addField( 
     282               new dcFieldText('comment_email','', array( 
     283                    'maxlength'         => 255, 
     284                    'required'     => true, 
     285                    'label'        => __('Email:')))) 
     286          ->addField( 
     287               new dcFieldText('comment_site','', array( 
     288                    'maxlength'         => 255, 
     289                    'label'        => __('Web site:')))) 
     290          ->addField( 
     291               new dcFieldTextArea('comment_content','', array( 
     292                    'required'     => true, 
     293                    'label'        => __('Comment:')))) 
     294          ->addField( 
     295               new dcFieldSubmit('add',__('Save'),array( 
     296                    'action' => 'addComment'))) 
     297          ; 
     298 
     299      
     300} 
     301 
     302$form->setup(); 
    285303 
    286304/* DISPLAY 
     
    293311     $default_tab = 'comments'; 
    294312} 
    295  
    296 if ($post_id) { 
    297      switch ($post_status) { 
    298           case 1: 
    299                $img_status = sprintf($img_status_pattern,__('Published'),'check-on.png'); 
    300                break; 
    301           case 0: 
    302                $img_status = sprintf($img_status_pattern,__('Unpublished'),'check-off.png'); 
    303                break; 
    304           case -1: 
    305                $img_status = sprintf($img_status_pattern,__('Scheduled'),'scheduled.png'); 
    306                break; 
    307           case -2: 
    308                $img_status = sprintf($img_status_pattern,__('Pending'),'check-wrn.png'); 
    309                break; 
    310           default: 
    311                $img_status = ''; 
    312      } 
    313      $edit_entry_str = __('&ldquo;%s&rdquo;'); 
    314      $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)).' '.$img_status; 
    315 } else { 
    316      $img_status = ''; 
    317 } 
    318  
    319  
    320 dcPage::open($page_title.' - '.__('Entries'), 
    321      dcPage::jsDatePicker(). 
    322      dcPage::jsToolBar(). 
    323      dcPage::jsModal(). 
    324      dcPage::jsMetaEditor(). 
    325      dcPage::jsLoad('js/_post.js'). 
    326      dcPage::jsConfirmClose('entry-form','comment-form'). 
    327      # --BEHAVIOR-- adminPostHeaders 
    328      $core->callBehavior('adminPostHeaders'). 
    329      dcPage::jsPageTabs($default_tab). 
    330      $next_headlink."\n".$prev_headlink, 
    331      dcPage::breadcrumb( 
     313$page_title_edit = __('Edit entry'); 
     314$_ctx 
     315     ->setBreadCrumb( 
    332316          array( 
    333317               html::escapeHTML($core->blog->name) => '', 
    334318               __('Entries') => 'posts.php', 
    335                '<span class="page-title">'.($post_id ? $page_title_edit : $page_title).'</span>' => '' 
    336           )) 
    337 ); 
    338  
    339 if (!empty($_GET['upd'])) { 
    340      dcPage::message(__('Entry has been successfully updated.')); 
    341 } 
    342 elseif (!empty($_GET['crea'])) { 
    343      dcPage::message(__('Entry has been successfully created.')); 
    344 } 
    345 elseif (!empty($_GET['attached'])) { 
    346      dcPage::message(__('File has been successfully attached.')); 
    347 } 
    348 elseif (!empty($_GET['rmattach'])) { 
    349      dcPage::message(__('Attachment has been successfully removed.')); 
    350 } 
    351  
    352 if (!empty($_GET['creaco'])) { 
    353      dcPage::message(__('Comment has been successfully created.')); 
    354 } 
    355  
    356 # XHTML conversion 
    357 if (!empty($_GET['xconv'])) 
    358 { 
    359      $post_excerpt = $post_excerpt_xhtml; 
    360      $post_content = $post_content_xhtml; 
    361      $post_format = 'xhtml'; 
    362       
    363      dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); 
    364 } 
    365  
    366 if ($post_id && $post->post_status == 1) { 
    367      echo '<p><a class="onblog_link" href="'.$post->getURL().'" onclick="window.open(this.href);return false;" title="'.$post_title.' ('.__('new window').')'.'">'.__('Go to this entry on the site').' <img src="images/outgoing-blue.png" alt="" /></a></p>'; 
    368 } 
    369 if ($post_id) 
    370 { 
    371      echo '<p class="nav_prevnext">'; 
    372      if ($prev_link) { echo $prev_link; } 
    373      if ($next_link && $prev_link) { echo ' | '; } 
    374      if ($next_link) { echo $next_link; } 
    375       
    376      # --BEHAVIOR-- adminPostNavLinks 
    377      $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null); 
    378       
    379      echo '</p>'; 
    380 } 
    381  
    382 # Exit if we cannot view page 
    383 if (!$can_view_page) { 
    384      dcPage::helpBlock('core_post'); 
    385      dcPage::close(); 
    386      exit; 
    387 } 
    388 /* Post form if we can edit post 
    389 -------------------------------------------------------- */ 
    390 if ($can_edit_post) 
    391 { 
    392      $sidebar_items = new ArrayObject(array( 
    393           'status-box' => array( 
    394                'title' => __('Status'), 
    395                'items' => array( 
    396                     'post_status' =>  
    397                          '<p class="entry-status"><label for="post_status" class="ib">'.__('Entry status').' '.$img_status.'</label>'. 
    398                          form::combo('post_status',$status_combo,$post_status,'maximal','',!$can_publish). 
    399                          '</p>', 
    400                     'post_dt' =>  
    401                          '<p><label for="post_dt" class="ib">'.__('Publication date and hour').'</label>'. 
    402                          form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). 
    403                          '</p>', 
    404                     'post_lang' => 
    405                          '<p><label for="post_lang" class="ib">'.__('Entry lang').'</label>'. 
    406                          form::combo('post_lang',$lang_combo,$post_lang). 
    407                          '</p>', 
    408                     'post_format' => 
    409                          '<p><label for="post_format" class="ib">'.__('Text formating').'</label>'. 
    410                          form::combo('post_format',$formaters_combo,$post_format,'maximal'). 
    411                          '</p>'. 
    412                          '<p>'.($post_id && $post_format != 'xhtml' ?  
    413                          '<a id="convert-xhtml" class="button maximal" href="post.php?id='.$post_id.'&amp;xconv=1">'. 
    414                          __('Convert to XHTML').'</a>' : '').'</p>')), 
    415           'metas-box' => array( 
    416                'title' => __('Ordering'), 
    417                'items' => array( 
    418                     'post_selected' =>  
    419                          '<p><label for="post_selected" class="classic">'. 
    420                          form::checkbox('post_selected',1,$post_selected).' '. 
    421                          __('Selected entry').'</label></p>', 
    422                     'cat_id' => 
    423                          '<p><label for="cat_id" class="ib">'.__('Category').'</label>'. 
    424                          form::combo('cat_id',$categories_combo,$cat_id,'maximal'). 
    425                          '</p>')), 
    426           'options-box' => array( 
    427                'title' => __('Options'), 
    428                'items' => array( 
    429                     'post_open_comment' => 
    430                          '<p><label for="post_open_comment" class="classic">'. 
    431                          form::checkbox('post_open_comment',1,$post_open_comment).' '. 
    432                          __('Accept comments').'</label></p>'. 
    433                          ($core->blog->settings->system->allow_comments ?  
    434                               (isContributionAllowed($post_id,strtotime($post_dt),true) ?  
    435                                    '' : 
    436                                    '<p class="form-note warn">'. 
    437                                    __('Warning: Comments are not more accepted for this entry.').'</p>') :  
    438                               '<p class="form-note warn">'. 
    439                               __('Warning: Comments are not accepted on this blog.').'</p>'), 
    440                     'post_open_tb' => 
    441                          '<p><label for="post_open_tb" class="classic">'. 
    442                          form::checkbox('post_open_tb',1,$post_open_tb).' '. 
    443                          __('Accept trackbacks').'</label></p>'. 
    444                          ($core->blog->settings->system->allow_trackbacks ?  
    445                               (isContributionAllowed($post_id,strtotime($post_dt),false) ?  
    446                                    '' : 
    447                                    '<p class="form-note warn">'. 
    448                                    __('Warning: Trackbacks are not more accepted for this entry.').'</p>') :  
    449                               '<p class="form-note warn">'.__('Warning: Trackbacks are not accepted on this blog.').'</p>'), 
    450                     'post_password' => 
    451                          '<p><label for="post_password" class="ib">'.__('Password').'</label>'. 
    452                          form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). 
    453                          '</p>', 
    454                     'post_url' => 
    455                          '<div class="lockable">'. 
    456                          '<p><label for="post_url" class="ib">'.__('Edit basename').'</label>'. 
    457                          form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). 
    458                          '</p>'. 
    459                          '<p class="form-note warn">'. 
    460                          __('Warning: If you set the URL manually, it may conflict with another entry.'). 
    461                          '</p></div>' 
    462      )))); 
    463  
    464      $main_items = new ArrayObject(array( 
    465           "post_title" => 
    466                '<p class="col">'. 
    467                '<label class="required no-margin"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 
    468                form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). 
    469                '</p>', 
    470            
    471           "post_excerpt" => 
    472                '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').'<span class="form-note">'. 
    473                __('Add an introduction to the post.').'</span></label> '. 
    474                form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). 
    475                '</p>', 
    476            
    477           "post_content" => 
    478                '<p class="area"><label class="required" '. 
    479                'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 
    480                form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). 
    481                '</p>', 
    482            
    483           "post_notes" => 
    484                '<p class="area" id="notes-area"><label for="post_notes">'.__('Personal notes:').'<span class="form-note">'. 
    485                __('Add unpublished notes.').'</span></label>'. 
    486                form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). 
    487                '</p>' 
    488           ) 
    489      ); 
    490       
    491      # --BEHAVIOR-- adminPostFormItems 
    492      $core->callBehavior('adminPostFormItems',$main_items,$sidebar_items, isset($post) ? $post : null); 
    493  
    494      echo '<div class="multi-part" title="'.($post_id ? __('Edit entry') : __('New entry')).'" id="edit-entry">'; 
    495      echo '<form action="post.php" method="post" id="entry-form">'; 
    496      echo '<div id="entry-wrapper">'; 
    497      echo '<div id="entry-content"><div class="constrained">'; 
    498  
    499      echo '<h3 class="hidden">'.__('Edit post').'</h3>'; 
    500       
    501      foreach ($main_items as $id => $item) { 
    502           echo $item; 
    503      } 
    504  
    505      # --BEHAVIOR-- adminPostForm (may be deprecated) 
    506      $core->callBehavior('adminPostForm',isset($post) ? $post : null); 
    507       
    508      echo 
    509      '<p class="border-top">'. 
    510      ($post_id ? form::hidden('id',$post_id) : ''). 
    511      '<input type="submit" value="'.__('Save').' (s)" '. 
    512      'accesskey="s" name="save" /> '; 
    513      if ($post_id) { 
    514           $preview_url = 
    515           $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 
    516           http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 
    517           '/'.$post->post_url); 
    518           echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a> '; 
    519      } else { 
    520           echo 
    521           '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; 
    522      } 
    523  
    524      echo 
    525      ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). 
    526      $core->formNonce(). 
    527      '</p>'; 
    528       
    529      echo '</div></div>';          // End #entry-content 
    530      echo '</div>';      // End #entry-wrapper 
    531  
    532      echo '<div id="entry-sidebar">'; 
    533       
    534      foreach ($sidebar_items as $id => $c) { 
    535           echo '<div id="'.$id.'" class="box">'. 
    536                '<h4>'.$c['title'].'</h4>'; 
    537           foreach ($c['items'] as $e_name=>$e_content) { 
    538                echo $e_content; 
    539           } 
    540           echo '</div>'; 
    541      } 
    542       
    543       
    544      # --BEHAVIOR-- adminPostFormSidebar (may be deprecated) 
    545      $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null); 
    546      echo '</div>';      // End #entry-sidebar 
    547  
    548      echo '</form>'; 
    549       
    550      # --BEHAVIOR-- adminPostForm 
    551      $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null); 
    552       
    553      echo '</div>'; 
    554       
    555      if ($post_id && $post->post_status == 1) { 
    556           echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'. 
    557           __('Ping blogs').'</a></p>'; 
    558      } 
    559       
    560 } 
    561  
    562  
    563 /* Comments and trackbacks 
    564 -------------------------------------------------------- */ 
    565 if ($post_id) 
    566 { 
    567      $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 
    568       
    569      $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); 
    570      $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1))); 
    571       
    572      # Actions combo box 
    573      $combo_action = array(); 
    574      if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id)) 
    575      { 
    576           $combo_action[__('Publish')] = 'publish'; 
    577           $combo_action[__('Unpublish')] = 'unpublish'; 
    578           $combo_action[__('Mark as pending')] = 'pending'; 
    579           $combo_action[__('Mark as junk')] = 'junk'; 
    580      } 
    581       
    582      if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id)) 
    583      { 
    584           $combo_action[__('Delete')] = 'delete'; 
    585      } 
    586       
    587      # --BEHAVIOR-- adminCommentsActionsCombo 
    588      $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); 
    589       
    590      $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); 
    591       
    592      echo 
    593      '<div id="comments" class="multi-part" title="'.__('Comments').'">'; 
    594       
    595      if ($has_action) { 
    596           echo '<form action="comments_actions.php" id="form-comments" method="post">'; 
    597      } 
    598       
    599      echo '<h3>'.__('Trackbacks').'</h3>'; 
    600       
    601      if (!$trackbacks->isEmpty()) { 
    602           showComments($trackbacks,$has_action,true); 
    603      } else { 
    604           echo '<p>'.__('No trackback').'</p>'; 
    605      } 
    606       
    607      echo '<h3>'.__('Comments').'</h3>'; 
    608      if (!$comments->isEmpty()) { 
    609           showComments($comments,$has_action); 
    610      } else { 
    611           echo '<p>'.__('No comment').'</p>'; 
    612      } 
    613       
    614      if ($has_action) { 
    615           echo 
    616           '<div class="two-cols">'. 
    617           '<p class="col checkboxes-helpers"></p>'. 
    618            
    619           '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. 
    620           form::combo('action',$combo_action). 
    621           form::hidden('redir','post.php?id='.$post_id.'&amp;co=1'). 
    622           $core->formNonce(). 
    623           '<input type="submit" value="'.__('ok').'" /></p>'. 
    624           '</div>'. 
    625           '</form>'; 
    626      } 
    627       
    628      echo '</div>'; 
    629 } 
    630  
    631 /* Add a comment 
    632 -------------------------------------------------------- */ 
    633 if ($post_id) 
    634 { 
    635      echo 
    636      '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'. 
    637      '<h3>'.__('Add a comment').'</h3>'. 
    638       
    639      '<form action="comment.php" method="post" id="comment-form">'. 
    640      '<div class="constrained">'. 
    641      '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').'</label>'. 
    642      form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). 
    643      '</p>'. 
    644       
    645      '<p><label for="comment_email">'.__('Email:').'</label>'. 
    646      form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). 
    647      '</p>'. 
    648       
    649      '<p><label for="comment_site">'.__('Web site:').'</label>'. 
    650      form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). 
    651      '</p>'. 
    652       
    653      '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. 
    654      __('Comment:').'</label> '. 
    655      form::textarea('comment_content',50,8,html::escapeHTML('')). 
    656      '</p>'. 
    657       
    658      '<p>'.form::hidden('post_id',$post_id). 
    659      $core->formNonce(). 
    660      '<input type="submit" name="add" value="'.__('Save').'" /></p>'. 
    661      '</div>'. 
    662      '</form>'. 
    663      '</div>'; 
    664 } 
    665  
    666 # Controls comments or trakbacks capabilities 
    667 function isContributionAllowed($id,$dt,$com=true) 
    668 { 
    669      global $core; 
    670  
    671      if (!$id) { 
    672           return true; 
    673      } 
    674      if ($com) { 
    675           if (($core->blog->settings->system->comments_ttl == 0) ||  
    676                (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { 
    677                return true; 
    678           } 
    679      } else { 
    680           if (($core->blog->settings->system->trackbacks_ttl == 0) ||  
    681                (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { 
    682                return true; 
    683           } 
    684      } 
    685      return false; 
    686 } 
    687  
    688 # Show comments or trackbacks 
    689 function showComments($rs,$has_action,$tb=false) 
    690 { 
    691      echo 
    692      '<table class="comments-list"><tr>'. 
    693      '<th colspan="2">'.__('Author').'</th>'. 
    694      '<th>'.__('Date').'</th>'. 
    695      '<th class="nowrap">'.__('IP address').'</th>'. 
    696      '<th>'.__('Status').'</th>'. 
    697      '<th>&nbsp;</th>'. 
    698      '</tr>'; 
    699       
    700      while($rs->fetch()) 
    701      { 
    702           $comment_url = 'comment.php?id='.$rs->comment_id; 
    703            
    704           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    705           switch ($rs->comment_status) { 
    706                case 1: 
    707                     $img_status = sprintf($img,__('Published'),'check-on.png'); 
    708                     break; 
    709                case 0: 
    710                     $img_status = sprintf($img,__('Unpublished'),'check-off.png'); 
    711                     break; 
    712                case -1: 
    713                     $img_status = sprintf($img,__('Pending'),'check-wrn.png'); 
    714                     break; 
    715                case -2: 
    716                     $img_status = sprintf($img,__('Junk'),'junk.png'); 
    717                     break; 
    718           } 
    719            
    720           echo 
    721           '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. 
    722           ' id="c'.$rs->comment_id.'">'. 
    723            
    724           '<td class="nowrap">'. 
    725           ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'. 
    726           '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'. 
    727           '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. 
    728           '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. 
    729           '<td class="nowrap status">'.$img_status.'</td>'. 
    730           '<td class="nowrap status"><a href="'.$comment_url.'">'. 
    731           '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'. 
    732            
    733           '</tr>'; 
    734      } 
    735       
    736      echo '</table>'; 
    737 } 
    738  
    739 dcPage::helpBlock('core_post','core_trackbacks','core_wiki'); 
    740 dcPage::close(); 
     319               ($post_id ? $page_title_edit : $page_title) => '' 
     320     )) 
     321     ->default_tab = $default_tab; 
     322 
     323$core->tpl->display('post.html.twig'); 
    741324?> 
  • admin/posts.php

    r1426 r1490  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1212 
    1313require dirname(__FILE__).'/../inc/admin/prepend.php'; 
    14  
     14global $_ctx; 
    1515dcPage::check('usage,contentadmin'); 
    1616 
     
    4848     # Filter form we'll put in html_block 
    4949     $users_combo = $categories_combo = array(); 
    50      $users_combo['-'] = $categories_combo['-'] = ''; 
    5150     while ($users->fetch()) 
    5251     { 
     
    6160     } 
    6261      
    63      $categories_combo[__('None')] = 'NULL'; 
     62 
     63# Getting categories 
     64$categories_combo = array(); 
     65try { 
     66     $categories = $core->blog->getCategories(array('post_type'=>'post')); 
    6467     while ($categories->fetch()) { 
    65           $categories_combo[str_repeat('&nbsp;&nbsp;',$categories->level-1).($categories->level-1 == 0 ? '' : '&bull; '). 
    66                html::escapeHTML($categories->cat_title). 
    67                ' ('.$categories->nb_post.')'] = $categories->cat_id; 
     68          $categories_combo[$categories->cat_id] =  
     69               str_repeat('&nbsp;&nbsp;',$categories->level-1). 
     70               ($categories->level-1 == 0 ? '' : '&bull; '). 
     71               html::escapeHTML($categories->cat_title); 
    6872     } 
    69       
     73} catch (Exception $e) { } 
    7074     $status_combo = array( 
    71      '-' => '' 
    7275     ); 
    7376     foreach ($core->blog->getAllPostStatus() as $k => $v) { 
    74           $status_combo[$v] = (string) $k; 
     77          $status_combo[(string) $k] = (string)$v; 
    7578     } 
    7679      
    7780     $selected_combo = array( 
    78      '-' => '', 
    79      __('Selected') => '1', 
    80      __('Not selected') => '0' 
     81     '1' => __('is selected'), 
     82     '0' => __('is not selected') 
    8183     ); 
    8284      
    8385     # Months array 
    84      $dt_m_combo['-'] = ''; 
    8586     while ($dates->fetch()) { 
    86           $dt_m_combo[dt::str('%B %Y',$dates->ts())] = $dates->year().$dates->month(); 
     87          $dt_m_combo[$dates->year().$dates->month()] = dt::str('%B %Y',$dates->ts()); 
    8788     } 
    8889      
    89      $lang_combo['-'] = ''; 
    9090     while ($langs->fetch()) { 
    9191          $lang_combo[$langs->post_lang] = $langs->post_lang; 
    9292     } 
    93       
    94      $sortby_combo = array( 
    95      __('Date') => 'post_dt', 
    96      __('Title') => 'post_title', 
    97      __('Category') => 'cat_title', 
    98      __('Author') => 'user_id', 
    99      __('Status') => 'post_status', 
    100      __('Selected') => 'post_selected' 
    101      ); 
    102       
    103      $order_combo = array( 
    104      __('Descending') => 'desc', 
    105      __('Ascending') => 'asc' 
    106      ); 
    10793} 
     94$form = new dcForm($core,'post','post.php'); 
     95 
    10896 
    10997# Actions combo box 
     
    138126$core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); 
    139127 
    140 /* Get posts 
    141 -------------------------------------------------------- */ 
    142 $user_id = !empty($_GET['user_id']) ?   $_GET['user_id'] : ''; 
    143 $cat_id = !empty($_GET['cat_id']) ?     $_GET['cat_id'] : ''; 
    144 $status = isset($_GET['status']) ? $_GET['status'] : ''; 
    145 $selected = isset($_GET['selected']) ?  $_GET['selected'] : ''; 
    146 $month = !empty($_GET['month']) ?       $_GET['month'] : ''; 
    147 $lang = !empty($_GET['lang']) ?         $_GET['lang'] : ''; 
    148 $sortby = !empty($_GET['sortby']) ?     $_GET['sortby'] : 'post_dt'; 
    149 $order = !empty($_GET['order']) ?       $_GET['order'] : 'desc'; 
    150128 
    151 $show_filters = false; 
    152129 
    153 $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; 
    154 $nb_per_page =  30; 
    155  
    156 if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { 
    157      if ($nb_per_page != $_GET['nb']) { 
    158           $show_filters = true; 
     130class monthdcFilterCombo extends dcFilterCombo { 
     131     public function applyFilter($params) { 
     132          $month=$this->avalues['values'][0]; 
     133          $params['post_month'] = substr($month,4,2); 
     134          $params['post_year'] = substr($month,0,4); 
    159135     } 
    160      $nb_per_page = (integer) $_GET['nb']; 
    161136} 
    162137 
    163 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); 
    164 $params['no_content'] = true; 
     138class PostsFetcher extends dcListFetcher { 
    165139 
    166 # - User filter 
    167 if ($user_id !== '' && in_array($user_id,$users_combo)) { 
    168      $params['user_id'] = $user_id; 
    169      $show_filters = true; 
    170 } else { 
    171      $user_id=''; 
    172 } 
     140     public function getEntries($params,$offset,$limit) { 
     141          $params['limit'] = array($offset,$limit); 
     142          return $this->core->blog->getPosts($params); 
     143     } 
    173144 
    174 # - Categories filter 
    175 if ($cat_id !== '' && in_array($cat_id,$categories_combo)) { 
    176      $params['cat_id'] = $cat_id; 
    177      $show_filters = true; 
    178 } else { 
    179      $cat_id=''; 
    180 } 
    181  
    182 # - Status filter 
    183 if ($status !== '' && in_array($status,$status_combo)) { 
    184      $params['post_status'] = $status; 
    185      $show_filters = true; 
    186 } else { 
    187      $status=''; 
    188 } 
    189  
    190 # - Selected filter 
    191 if ($selected !== '' && in_array($selected,$selected_combo)) { 
    192      $params['post_selected'] = $selected; 
    193      $show_filters = true; 
    194 } else { 
    195      $selected=''; 
    196 } 
    197  
    198 # - Month filter 
    199 if ($month !== '' && in_array($month,$dt_m_combo)) { 
    200      $params['post_month'] = substr($month,4,2); 
    201      $params['post_year'] = substr($month,0,4); 
    202      $show_filters = true; 
    203 } else { 
    204      $month=''; 
    205 } 
    206  
    207 # - Lang filter 
    208 if ($lang !== '' && in_array($lang,$lang_combo)) { 
    209      $params['post_lang'] = $lang; 
    210      $show_filters = true; 
    211 } else { 
    212      $lang=''; 
    213 } 
    214  
    215 # - Sortby and order filter 
    216 if ($sortby !== '' && in_array($sortby,$sortby_combo)) { 
    217      if ($order !== '' && in_array($order,$order_combo)) { 
    218           $params['order'] = $sortby.' '.$order; 
    219      } else { 
    220           $order='desc'; 
     145     public function getEntriesCount($params) { 
     146          $count = $this->core->blog->getPosts($params,true); 
     147          return $count->f(0); 
    221148     } 
    222       
    223      if ($sortby != 'post_dt' || $order != 'desc') { 
    224           $show_filters = true; 
    225      } 
    226 } else { 
    227      $sortby='post_dt'; 
    228      $order='desc'; 
    229 } 
    230  
    231 # Get posts 
    232 try { 
    233      $posts = $core->blog->getPosts($params); 
    234      $counter = $core->blog->getPosts($params,true); 
    235      $post_list = new adminPostList($core,$posts,$counter->f(0)); 
    236 } catch (Exception $e) { 
    237      $core->error->add($e->getMessage()); 
    238149} 
    239150 
    240151/* DISPLAY 
    241152-------------------------------------------------------- */ 
    242 $starting_script = dcPage::jsLoad('js/_posts_list.js'); 
    243 if (!$show_filters) { 
    244      $starting_script .= dcPage::jsLoad('js/filter-controls.js'); 
    245 } 
     153$filterSet = new dcFilterSet($core,'fposts','posts.php'); 
    246154 
    247 dcPage::open(__('Entries'),$starting_script, 
    248      dcPage::breadcrumb( 
    249           array( 
    250                html::escapeHTML($core->blog->name) => '', 
    251                '<span class="page-title">'.__('Entries').'</span>' => '' 
    252           )) 
    253 ); 
     155$filterSet 
     156     ->addFilter(new dcFilterRichCombo( 
     157          'users',__('Author'), __('Author'), 'user_id', $users_combo,array( 
     158               'multiple' => true))) 
     159     ->addFilter(new dcFilterRichCombo( 
     160          'category',__('Category'), __('Category'), 'cat_id', $categories_combo)) 
     161     ->addFilter(new dcFilterRichCombo( 
     162          'post_status',__('Status'), __('Status'), 'post_status', $status_combo)) 
     163     ->addFilter(new dcFilterRichCombo( 
     164          'lang',__('Lang'), __('Lang'), 'post_lang', $lang_combo)) 
     165     ->addFilter(new dcFilterCombo( 
     166          'selected',__('Selected'), __('The post : '),'post_selected', $selected_combo)) 
     167     ->addFilter(new monthdcFilterCombo( 
     168          'month',__('Month'),__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1))) 
     169     ->addFilter(new dcFilterText( 
     170          'search',__('Contains'),__('The entry contains'), 'search',20,255)); 
    254171 
    255 if (!$core->error->flag()) 
    256 { 
    257      echo 
    258      '<p class="top-add"><a class="button add" href="post.php">'.__('New entry').'</a></p>'; 
    259       
    260      if (!$show_filters) { 
    261           echo '<p><a id="filter-control" class="form-control" href="#">'. 
    262           __('Filter posts list').'</a></p>'; 
    263      } 
    264       
    265      echo 
    266      '<form action="posts.php" method="get" id="filters-form">'. 
    267      '<h3>'.__('Filter posts list').'</h3>'. 
    268172 
    269      '<div class="table">'. 
    270      '<div class="cell">'. 
    271      '<p><label for="user_id" class="ib">'.__('Author:').'</label> '. 
    272      form::combo('user_id',$users_combo,$user_id).'</p>'. 
    273      '<p><label for="cat_id" class="ib">'.__('Category:').'</label> '. 
    274      form::combo('cat_id',$categories_combo,$cat_id).'</p>'. 
    275      '<p><label for="status" class="ib">'.__('Status:').'</label> ' . 
    276      form::combo('status',$status_combo,$status).'</p> '. 
    277      '</div>'. 
    278       
    279      '<div class="cell">'. 
    280      '<p><label for="selected" class="ib">'.__('Selected:').'</label> '. 
    281      form::combo('selected',$selected_combo,$selected).'</p>'. 
    282      '<p><label for="month" class="ib">'.__('Month:').'</label> '. 
    283      form::combo('month',$dt_m_combo,$month).'</p>'. 
    284      '<label for="lang" class="ib">'.__('Lang:').'</label> '. 
    285      form::combo('lang',$lang_combo,$lang).'</p> '. 
    286      '</div>'. 
    287       
    288      '<div class="cell filters-options">'. 
    289      '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. 
    290      form::combo('sortby',$sortby_combo,$sortby).'</p>'. 
    291      '<p><label for="order" class="ib">'.__('Sort:').'</label> '. 
    292      form::combo('order',$order_combo,$order).'</p>'. 
    293      '<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'. 
    294      form::field('nb',3,3,$nb_per_page).' '. 
    295      __('entries per page').'</label></p>'. 
    296      '</div>'. 
    297      '</div>'. 
     173$lfetcher = new PostsFetcher($core); 
     174$lposts = new dcItemList ($core,array('lposts','form-entries'),$filterSet,$lfetcher,'posts_actions.php'); 
     175$lposts->addTemplate('posts_cols.html.twig'); 
    298176 
    299      '<p><input type="submit" value="'.__('Apply filters').'" />'. 
    300      '<br class="clear" /></p>'. //Opera sucks 
    301      '</form>'; 
    302       
    303      # Show posts 
    304      $post_list->display($page,$nb_per_page, 
    305      '<form action="posts_actions.php" method="post" id="form-entries">'. 
    306       
    307      '%s'. 
    308       
    309      '<div class="two-cols">'. 
    310      '<p class="col checkboxes-helpers"></p>'. 
    311       
    312      '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '. 
    313      form::combo('action',$combo_action). 
    314      '<input type="submit" value="'.__('ok').'" /></p>'. 
    315      form::hidden(array('user_id'),$user_id). 
    316      form::hidden(array('cat_id'),$cat_id). 
    317      form::hidden(array('status'),$status). 
    318      form::hidden(array('selected'),$selected). 
    319      form::hidden(array('month'),$month). 
    320      form::hidden(array('lang'),$lang). 
    321      form::hidden(array('sortby'),$sortby). 
    322      form::hidden(array('order'),$order). 
    323      form::hidden(array('page'),$page). 
    324      form::hidden(array('nb'),$nb_per_page). 
    325      $core->formNonce(). 
    326      '</div>'. 
    327      '</form>' 
    328      ); 
    329 } 
     177$lposts 
     178     ->addColumn(new dcColumn('title',__('Title'),'post_title')) 
     179     ->addColumn(new dcColumn('cat',__('Category'),'cat_title')) 
     180     ->addColumn(new dcColumn('date',__('Date'),'post_date')) 
     181     ->addColumn(new dcColumn('datetime',__('Date and Time'),'post_dt')) 
     182     ->addColumn(new dcColumn('author',__('Author'),'user_id')) 
     183     ->addColumn(new dcColumn('status',__('Status'),'post_status')); 
    330184 
    331 dcPage::helpBlock('core_posts'); 
    332 dcPage::close(); 
     185 
     186$lposts->setup(); 
     187 
     188$_ctx 
     189     ->setBreadCrumb(array(__('Entries') => 'posts.php')); 
     190 
     191 
     192$core->tpl->display('posts.html.twig'); 
     193 
     194 
    333195?> 
  • admin/style/default.css

    r1413 r1490  
    3636} 
    3737 
    38 h1, h2, h3, h4, h5, h6, p { 
     38h1, h2, h3, .as_h3, h4, h5, h6, p { 
    3939     margin-top: 0; 
    4040     margin-bottom: 1rem; 
     
    5353     color: #d30e60; 
    5454} 
     55.page-title img { 
     56     padding-left: .6rem; 
     57     vertical-align: middle; 
     58} 
    5559#content > h2 { 
    5660     padding: 0 1.8rem .6rem; 
     
    5862     background: #fff url(bg_h2.png) repeat-x center bottom; 
    5963} 
    60 h3 { 
     64h3, .as_h3 { 
    6165     color: #575859; 
    6266     font-size: 1.4rem; 
     67} 
     68h4 { 
     69     font-size: 1.1em; 
     70     color: #575859; 
     71} 
     72h5 { 
     73     font-size: 1em; 
     74     color: #575859; 
     75} 
     76#entry-sidebar h5 { 
     77     font-weight: normal; 
     78     color: #333; 
     79} 
     80.entry-status label img { 
     81     padding-left: .4rem; 
     82     vertical-align: text-top; 
    6383} 
    6484p, div.p { 
     
    232252} 
    233253.two-cols .col { 
    234      width: 49%; 
     254     width: 47%; 
    235255     margin-left: 2%; 
    236256     float: left; 
    237257} 
    238 .two-cols .col:first-child { 
    239      width: 49%; 
    240      margin-left: 0; 
    241 } 
    242258.two-cols .col70{ 
    243      width: 69%; 
     259     width: 68%; 
    244260     margin-left: 0; 
    245261     float: left; 
    246262} 
    247 .two-cols .col30 { 
     263.col30 { 
    248264     width: 28%; 
    249265     margin-left: 2%; 
    250266     float: left; 
    251267} 
     268.two-cols .col:first-child, 
     269.two-cols .col30.first-col { 
     270     margin-left: 0; 
     271     margin-right: 2%; 
     272} 
     273.two-cols .col:last-child, 
     274.two-cols .col70.last-col { 
     275     margin-left: 2%; 
     276     margin-right: 0; 
     277} 
    252278/* -------------------------------------------------------------- layout - onglets */ 
    253279.part-tabs ul { 
    254      padding: .5em 0 .3em 1em; 
    255      border-bottom: 1px solid #ccc; 
     280     padding: .5em 0 .3em 1.2rem; 
     281     border-bottom: 1px solid #ddd; 
    256282} 
    257283.part-tabs li { 
     
    261287} 
    262288.part-tabs li a { 
    263      padding: .5em 0.5em; 
    264      margin-right: .5em; 
    265      border: 1px solid #ccc; 
     289     padding: .5em 2em; 
     290     margin-right: -1px; 
     291     border: 1px solid #aaa; 
    266292     border-bottom: none; 
    267      background: #dfdfdf; 
    268293     text-decoration: none; 
    269      color: #000; 
    270      background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #dfdfdf), color-stop(1, #fafafa) ); 
    271      background:-moz-linear-gradient( center top, #dfdfdf 5%, #fafafa 100% ); 
    272      filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfdfdf', endColorstr='#fafafa'); 
    273      background-color:#ededed; 
    274 } 
    275 .part-tabs li.part-tabs-link a { 
    276      background: #ffe; 
     294     color: #333; 
     295     background-color:#E4E0EC; 
    277296} 
    278297.part-tabs li a:hover, .part-tabs li a:focus { 
     
    283302.part-tabs li.part-tabs-active a { 
    284303     background: #fff; 
    285      border: 1px solid #d30e60; 
    286      color: #d30e60; 
    287304     font-weight: bold; 
    288305     border-bottom-color: #fff; 
     306     padding-bottom: .7rem; 
    289307} 
    290308/* ------------------------------------------------------------------ main-menu */ 
     
    293311     float: left; 
    294312     margin:0; 
    295      padding-top: .5em; 
     313     padding-top: 4.5em; 
    296314     padding-bottom: 1em; 
    297315     background: #f7f7f7; 
     
    318336     background-repeat: no-repeat; 
    319337     background-position: 8px .3em; 
     338} 
     339#main-menu li.active { 
     340     background-color: #fff; 
    320341} 
    321342#main-menu a { 
     
    356377     background: #dfdfdf; 
    357378     border-color: #999; 
    358      color: #666; 
     379     color: #444; 
    359380     border-bottom-right-radius: .6em; 
    360381     border-top-right-radius: .6em; 
     
    378399     color: #000; 
    379400     font-variant: small-caps; 
    380 } 
    381 #favorites-menu a { 
    382      color: #333; 
     401     padding-top: .6rem; 
    383402} 
    384403/* ------------------------------------------------------------------ footer */ 
     
    416435     padding: 1em 1em 0 1em; 
    417436     border-radius: 4px; 
     437     background: #fff; 
    418438} 
    419439#login-screen legend { 
     
    432452/* ------------------------------------------------------------------ dashboard */ 
    433453#dashboard-main { 
    434      float: left; 
    435      overflow: hidden; 
    436      padding: 1em 2% 1em 0; 
    437      width: 70%; 
    438 } 
    439 #dashboard-main.fullwidth { 
    440      width: 100%; 
    441454     padding: 1em 0; 
    442      float: none; 
    443455} 
    444456#icons { 
     
    450462     width: 210px; 
    451463     text-align: center; 
    452      margin: 2em 0; 
     464     margin: 1em 0 2em; 
     465     padding: 1em 0; 
    453466     display:inline-block; 
     467     vertical-align: top; 
    454468} 
    455469#icons a, 
     
    463477#icons a span { 
    464478     border-bottom: 1px dotted #f90; 
     479     color: #333; 
     480} 
     481#icons a img { 
     482     padding: 2em; 
     483     background: #eee; 
     484     border-radius: 1.6rem; 
     485     box-shadow: 0 3px 3px 0 #ccc; 
     486     margin-bottom: .6rem; 
     487} 
     488#icons a img:hover, #icons a:focus img { 
     489     background-color: #BBDB58; 
    465490} 
    466491#icons a:focus span, #icons a:hover span { 
     
    468493} 
    469494#quick { 
    470      clear: left; 
    471495     margin-top: 2em; 
    472496} 
     
    483507} 
    484508#dashboard-items { 
    485      float: left; 
    486      width: 27%; 
    487      overflow: hidden; 
    488      padding-bottom: 1em; 
    489      padding-top: 3em; 
     509     margin: 3em auto; 
     510     display: table; 
     511     width: 100%; 
     512     border-collapse: collapse; 
     513} 
     514.db-item { 
     515     display: table-cell; 
     516     padding: 1em 3em; 
     517     vertical-align: top; 
     518     border: 1px solid #ccc; 
    490519} 
    491520#dashboard-items img { 
     
    512541} 
    513542 
    514 #upg-notify { 
    515 } 
    516 #upg-notify ul { 
    517      padding-left: 15px; 
    518 } 
    519 #upg-notify li { 
    520      color: #fff; 
    521 } 
    522543/* ------------------------------------------------------------------ post */ 
    523544#entry-wrapper { 
     
    528549#entry-content { 
    529550     margin-right: 19em; 
    530      margin-left: 1.2rem; 
     551     margin-left: 0; 
     552} 
     553.multi-part { 
     554     padding-left: 1.2rem; 
     555} 
     556#entry-content label { 
     557     text-transform: uppercase; 
     558     font-weight: bold; 
     559     margin-top: 2em; 
    531560} 
    532561#entry-sidebar { 
     
    534563     float: right; 
    535564} 
     565#entry-sidebar input[type="text"], 
     566#entry-sidebar select { 
     567     width: 14em; /* to prevent inline with label */ 
     568} 
     569.box { 
     570     border-bottom: 1px solid #ddd; 
     571     margin-bottom: 1em; 
     572} 
    536573#comments { 
    537574     clear: both; 
    538 } 
    539 .preview_entry a { 
    540      border: 1px solid #ccc; 
    541      padding: .2rem .5rem; 
    542      background: #eef; 
    543575} 
    544576/* ------------------------------------------------------------------ categories */ 
     
    575607} 
    576608#media-details { 
     609} 
     610.near-icon { 
    577611     margin-left: 70px; 
     612     margin-bottom: 3em; 
    578613} 
    579614#media-details ul { 
     
    710745/* -------------------------------------------------------------------- Themes */ 
    711746#themes { 
    712      border-bottom: 1px solid #ccc; 
    713      margin: 1em 0; 
     747     margin: 0; 
     748     width: 100%; 
     749     padding: 0; 
     750} 
     751#themes h3 { 
    714752} 
    715753#themes div.theme-details { 
    716      clear: left; 
    717754     border-top: 1px solid #ccc; 
    718      padding: 1em 0; 
     755     padding: 12px; 
     756     display: inline-block; 
     757     vertical-align: top; 
     758     width: 284px; 
     759} 
     760.current-theme { 
     761     background: #eef; 
    719762} 
    720763#themes div.theme-details:hover { 
    721      background: #eee; 
     764     background: #f0f0f0; 
    722765} 
    723766#themes div.theme-details div.theme-shot { 
    724      float: left; 
    725767} 
    726768#themes div.theme-details div.theme-shot img { 
    727769     display: block; 
    728      width: 57px; 
    729      height: 50px; 
    730770     border: 1px solid #ccc; 
     771     margin-bottom: 1.5em; 
    731772} 
    732773#themes div.theme-details div.theme-info { 
    733      margin-left: 67px; 
    734774} 
    735775#themes div.theme-details div.theme-info span.theme-desc { 
     
    740780} 
    741781#themes div.theme-details div.theme-actions { 
    742      margin-left: 67px; 
    743 } 
     782} 
     783#themes-actions { 
     784     border-bottom: 1px solid #999; 
     785     margin-bottom: 3em; 
     786} 
     787.theme-css { 
     788     display: block; 
     789} 
     790 
    744791/* Themes list, JS version */ 
    745792#themes-wrapper { 
     793     display: table; 
     794} 
     795#themes-wrapper #themes { 
     796     display: table-cell; 
     797     vertical-align: top; 
     798     padding-left: 1em; 
    746799} 
    747800#theme-box { 
    748      border: 1px solid #999; 
    749      border-left: none; 
    750      padding: 5px; 
    751      float: right; 
    752      height: 420px; 
    753      width: 320px; 
    754      overflow: auto; 
     801     display: table-cell; 
     802     vertical-align: top; 
     803     padding: 1rem 0;  
     804     width: 312px; 
     805     background: #eef; 
     806     border: 1px solid #ccc; 
     807     border-radius: 3px; 
    755808} 
    756809#theme-box div.theme-shot img { 
    757810     display: block; 
    758      margin: 0 0 0 10px; 
     811     margin: 0 16px; 
    759812     width: 280px; 
    760813     height: 245px; 
     
    762815} 
    763816#theme-box div.theme-info { 
    764      margin: 1em 0 0 10px; 
    765 } 
    766 #theme-box h3 { 
    767      margin: 0; 
    768 } 
    769 #theme-box div.theme-info span { 
    770      display: block; 
     817     margin: 1em 16px; 
     818} 
     819#theme-box h4 { 
     820     color: #000; 
    771821} 
    772822#theme-box span.theme-version { 
     
    781831} 
    782832#theme-box div.theme-actions { 
    783      margin-left: 10px; 
    784 } 
    785 #themes-wrapper #themes { 
    786      border: 1px solid #999; 
    787      overflow: auto; 
    788      height: 420px; 
    789      padding: 5px; 
    790      margin: 0; 
     833     padding: 0 16px; 
    791834} 
    792835#themes div.theme-details-js { 
     
    794837     width: 120px; 
    795838     height: 150px; 
    796      margin: 0 10px 20px; 
    797      padding: 10px 10px 0; 
     839     margin: 0 12px 24px; 
     840     padding: 12px 12px 0; 
    798841     text-align: center; 
    799842     background: #f3f3f3; 
    800      border: 1px solid #f3f3f3; 
     843     border: 1px solid #ddd; 
    801844     cursor: pointer; 
    802845     border-radius: 4px; 
     
    806849} 
    807850#themes div.theme-details-js.theme-selected { 
    808      background: #E5E3DA; 
     851     background: #ddd; 
    809852     border: 1px solid #999; 
    810853} 
     
    813856     height: 105px; 
    814857     border: 1px solid #fff; 
    815 } 
    816 #themes div.theme-details-js h3 { 
    817      font-family: inherit; 
    818      font-weight: normal; 
    819      margin: 0; 
    820      padding: 0; 
    821858} 
    822859/* ----------------------------------------------------------  Plugins list */ 
     
    949986     color: #fff; 
    950987} 
    951 #content > .message, #content > .error { 
    952      margin-right: 14em 
    953 } 
    954988/* ------------------------------------------------------------------ navigation */ 
    955989.anchor-nav { 
     
    958992     padding: .4rem 1.2rem; 
    959993     float: right; 
     994} 
     995.nav_prevnext { 
     996     margin-bottom: 2em; 
     997     color: #fff; 
     998} 
     999.nav_prevnext a, a.back { 
     1000     border: 1px solid #ddd; 
     1001     padding: .2rem 2rem; 
     1002     border-radius: 1rem; 
     1003     background-color: #f0f0f0; 
     1004} 
     1005a.back:before { 
     1006     content: "\ab\a0"; 
     1007} 
     1008a.onblog_link { 
     1009     color: #333; 
     1010     float: right; 
     1011     border: 1px solid #eee; 
     1012     padding: .2rem 2rem; 
     1013     border-radius: 1rem; 
     1014     background-color: #ffe; 
    9601015} 
    9611016/* ------------------------------------------------------------------ debug */ 
     
    9821037/* -------------------------------------------------------------------- CLASSES COMMUNES */ 
    9831038 
    984 .no-margin { 
    985      margin: 0; 
     1039.no-margin, #entry-content label.no-margin { 
     1040     margin: 0; 
     1041} 
     1042.border-top { 
     1043     border-top: 1px solid #999; 
     1044     padding-top: 1em; 
     1045     margin-top:    1em; 
     1046} 
     1047.fieldset { 
     1048     background: #fff; 
     1049     border: 1px solid #aaa; 
     1050     border-radius: 6px;  
     1051     padding: 1em .7em .5em; 
     1052     margin-bottom: 1em; 
     1053} 
     1054.fieldset h3 { 
     1055     color: #333; 
    9861056} 
    9871057 
     
    10901160} 
    10911161 
    1092 th, td { 
     1162td { 
    10931163     border-width: 0 0 1px 0; 
    10941164     border-style: solid; 
     
    10981168} 
    10991169th { 
     1170     border-width: 1px 0 1px 0; 
     1171     border-style: solid; 
     1172     border-color: #ccc; 
     1173     background: #f3f3ff; 
     1174     padding: .4rem .5rem; 
     1175     vertical-align: top; 
    11001176     text-align: left; 
    1101      border-bottom-color: #aaa; 
    11021177} 
    11031178.noborder td, td.noborder, .noborder th, th.noborder { 
    1104      border-width: 0; 
     1179     border-width: 0 0 1px 0; 
     1180     border-color: #ddd; 
     1181     line-height: 2.4rem; 
     1182     padding-bottom: 0; 
     1183} 
     1184.noborder p { 
     1185     margin-bottom: 0; 
    11051186} 
    11061187table .maximal, table.maximal { 
     
    11161197table.settings, table.prefs { 
    11171198     width: 80%; 
     1199     border: 1px solid #999; 
     1200     margin-bottom: 3em;  
     1201} 
     1202table.settings th, table.prefs th { 
     1203     background: #eef; 
    11181204} 
    11191205table.settings th:first-child, table.prefs th:first-child { 
     
    11291215     width: 40%; 
    11301216} 
    1131  
    11321217td.status { 
    11331218     vertical-align: middle; 
     
    11681253     padding-left: 15px; 
    11691254} 
    1170  
    11711255/* ----------------------------------------------------------------- FORMS */ 
    11721256form { 
     
    11751259     padding: 0; 
    11761260} 
    1177 fieldset, .fieldset { 
     1261fieldset { 
    11781262     display: block; 
    11791263     margin: 0 0 1em 0; 
     
    11891273     border-width: 1px; 
    11901274     border-style: solid; 
    1191      border-color: #ccc; 
    1192      background: #f5f5f5; 
     1275     border-color: #333; 
     1276     background: #fff; 
    11931277     margin-bottom: 0.5em; 
     1278     border-radius: 3px; 
    11941279} 
    11951280optgroup { 
     
    12431328     font-style:italic; 
    12441329     font-weight: normal; 
     1330     text-transform: none; 
    12451331     color: #666; 
    12461332} 
     
    12541340} 
    12551341p.form-note.info { 
    1256      background: #eef url(info.png) no-repeat .3em .2em; 
    1257      border: 1px solid #99f; 
    1258 } 
    1259 .form-note a {border-bottom: 1px solid #99f;} 
    1260  
     1342     background: #f5eaff url(info.png) no-repeat .3em .2em; 
     1343     border: 1px solid #ddbaff; 
     1344} 
     1345.form-note a {border-bottom: 1px solid #ddbaff;} 
     1346 
     1347label.ib { 
     1348     display: inline-block; 
     1349} 
    12611350label.classic { 
    12621351     display: inline; 
     
    13071396a.form-control { 
    13081397     display: none; 
    1309      font-weight: bold; 
    1310      background: url(magnifier.png) no-repeat 0 0; 
    1311      color: green; 
     1398     background: url(../images/expand.png) no-repeat .4rem center; 
    13121399     padding-left: 20px; 
     1400     color: #000; 
    13131401} 
    13141402.constrained { 
     
    13251413input[type=button], 
    13261414a.button, 
    1327 a.back, 
    13281415a.submit { 
    13291416     display: inline-block; 
     
    13371424     margin-bottom: .1em; 
    13381425} 
     1426h4 a.button {font-weight: normal;} 
     1427 
    13391428/* validation */ 
    13401429input[type=submit], 
     
    13611450/* suppression et reset */ 
    13621451a.button, 
    1363 a.back, 
    13641452input[type=submit].reset, 
    13651453input[type=submit].delete { 
     
    13721460     } 
    13731461a.button:hover, 
    1374 a.back:hover, 
    13751462input[type=reset]:hover, 
    13761463input[type=submit].reset:hover, 
    13771464input[type=submit].delete:hover, 
    13781465a.button:focus, 
    1379 a.back:focus, 
    13801466input[type=reset]:focus, 
    13811467input[type=submit].reset:focus, 
     
    13901476input[type=submit].delete { 
    13911477     color: #c00; 
    1392      padding-bottom: .1em; 
     1478     padding-bottom: .2rem; 
    13931479} 
    13941480#entry-content .delete { 
     
    14111497     margin-left: 2em; 
    14121498} 
    1413 a.back:before { 
    1414      content: "\ab\a0"; 
    1415 } 
    14161499.button.add { 
    14171500     background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #9dce2c), color-stop(1, #8cb82b) ); 
     
    14211504     border:1px solid #83c41a; 
    14221505     padding:.6rem 1.8rem; 
    1423      text-shadow:1px 1px 0 #689324; 
    14241506     color: #000; 
    14251507     text-shadow: 1px 1px 0 #BBDB58; 
     
    14361518.button-add:focus { 
    14371519     outline: dotted 1px; 
    1438 } 
    1439 .button.add:active { 
    1440      position:relative; 
    1441      top:1px; 
    14421520} 
    14431521 
     
    14751553} 
    14761554 
     1555/* ------------------------------------------------------- Filters */ 
     1556#filters-form { 
     1557     border: 1px dashed #999; 
     1558     border-radius: .6rem; 
     1559     margin-bottom: 2em; 
     1560     padding: .5em 1em 0; 
     1561} 
     1562#filters-form .table { 
     1563     display: table; 
     1564     width: 100%; 
     1565     padding: 0; 
     1566     margin-bottom: 1em; 
     1567     margin-top: 1.5em; 
     1568} 
     1569#filters-form .cell { 
     1570     padding: 0 2em 0 0; 
     1571     display: table-cell; 
     1572     vertical-align: top; 
     1573} 
     1574#filters-form .filters-options { 
     1575     padding-left: 2em; 
     1576     border-left: 1px solid #ccc; 
     1577} 
     1578#filters-form label.ib, span.ib { 
     1579     width:7em; 
     1580     display: inline-block; 
     1581} 
     1582#filters-form label.ibw, span.ibw { 
     1583     width: 9em; 
     1584     display: inline-block; 
     1585} 
     1586#filters-form select { 
     1587     width: 14em; 
     1588} 
     1589 
     1590/* ---------------------------------------------------- Pagination */ 
     1591.pagination { 
     1592     height: 22px; 
     1593     margin-top: 1em; 
     1594     line-height: 22px; 
     1595     padding: 0 1rem;  
     1596     border: 1px solid #ddd; 
     1597     overflow: hidden;  
     1598     background: #e1e1e1;  
     1599     background: -moz-linear-gradient(center top , #f2f2f2, #e1e1e1);  
     1600     background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f2f2f2), color-stop(100%,#e1e1e1));  
     1601     -moz-border-radius: 4px;  
     1602     -webkit-border-radius: 4px;  
     1603     border-radius: 4px;  
     1604     clear: left; 
     1605} 
     1606.pagination a, .pagination strong { 
     1607     height: 20px; 
     1608     border: none; 
     1609     padding: 2px 6px;  
     1610     background-color : transparent; 
     1611     background-position : 50% 50%; 
     1612     background-repeat: no-repeat; 
     1613} 
     1614.pagination a:hover, .pagination strong { 
     1615     border-color : #ccc; 
     1616     background-color: #fff; 
     1617} 
     1618 
    14771619/* --------------------------------------------------------------------------- 
    14781620     Media queries vite fait en attendant la reprise complète du layout 
    14791621---------------------------------------------------------------------------- */ 
    14801622@media screen and (max-width: 920px) { 
    1481      #top, #top h1 a {width: 42px !important; height:100%; overflow: hidden;} 
     1623     #top, #top h1 a {width: 42px !important; height:100%; overflow: hidden; 
     1624} 
    14821625     #top h1 a:link { 
    14831626          background: transparent url(dc_logos/b-dotclear120.png) no-repeat -180px 6px;  
     
    14971640          line-height: 3.2rem; 
    14981641     } 
     1642     #info-box1 {margin-left: 1rem;} 
    14991643     #info-box1 select {width: 14rem;} 
    15001644     #main-menu, #main, #content, #content h2, #entry-wrapper, #entry-sidebar, #entry-content, .two-cols .col, .two-cols .col:first-child { 
     
    15151659     .smallscreen {display: none;} 
    15161660     #help-button {width:20px; overflow: hidden;} 
    1517      #info-box1 {margin-left: 1rem;} 
     1661     #info-box2 {float:none;} 
     1662     #dashboard-items div {display: block;margin-bottom: 1em; padding: 0 1em;} 
    15181663} 
    15191664@media screen and (max-width: 492px) { 
     
    15221667     .page-title, #info-boxes, .media-item {display: inline-block;} 
    15231668     div.media-list .media-item {width: 90%; float: none} 
     1669     #info-box1 select {width: 12rem; margin-right: .6rem;} 
    15241670     #info-box1 p.nomobile, label.nomobile {display: none;} 
    15251671     #help-button {height:26px; width:26px; background-color: #A2CBE9; padding: 0; margin:0;font-size: 1rem;line-height: 68px} 
  • inc/admin/lib.dc.page.php

    r1461 r1490  
    4949 
    5050     # Top of admin page 
    51      public static function open($title='',$head='',$breadcrumb='') 
     51     public static function open($title='', $head='') 
    5252     { 
    5353          global $core; 
     
    159159          } 
    160160 
    161           // Display breadcrumb (if given) before any error message 
    162           echo $breadcrumb; 
    163  
    164161          if ($core->error->flag()) { 
    165162               echo 
     
    213210     } 
    214211 
    215      public static function openPopup($title='',$head='',$breadcrumb='') 
     212     public static function openPopup($title='', $head='') 
    216213     { 
    217214          global $core; 
     
    258255          '<div id="content">'."\n"; 
    259256 
    260           // display breadcrumb if given 
    261           echo $breadcrumb; 
    262  
    263257          if ($core->error->flag()) { 
    264258               echo 
     
    279273     } 
    280274 
    281      public static function breadcrumb($elements=null,$with_home_link=true,$echo=false) 
     275     public static function breadcrumb($elements=null,$no_home_link=false) 
    282276     { 
    283277          // First item of array elements should be blog's name, System or Plugins 
    284           $res = '<h2>'.($with_home_link ? 
    285                '<a class="go_home" href="index.php"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>' : 
    286                '<img src="style/dashboard-alt.png" alt="" />'); 
     278          $res = '<h2>'.($no_home_link ? 
     279               '<img src="style/dashboard-alt.png" alt="" />' : 
     280               '<a class="go_home" href="index.php"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>'); 
    287281          $index = 0; 
    288282          foreach ($elements as $element => $url) { 
    289                $res .= ($with_home_link ? ($index == 1 ? ' : ' : ' &rsaquo; ') : ($index == 0 ? ' ' : ' &rsaquo; ')). 
    290                     ($url ? '<a href="'.$url.'">' : '').$element.($url ? '</a>' : ''); 
     283               $res .= ($no_home_link ? ' ' : ($index == 1 ? ' : ' : ' &rsaquo; ')).($url ? '<a href="'.$url.'">' : '').$element.($url ? '</a>' : ''); 
    291284               $index++; 
    292285          } 
    293286          $res .= '</h2>'; 
    294           if ($echo) { 
    295                echo $res; 
    296           } 
    297287          return $res; 
    298288     } 
     
    365355     { 
    366356          $args = func_get_args(); 
    367  
    368           $args = new ArrayObject($args); 
    369  
    370           # --BEHAVIOR-- adminPageHelpBlock 
    371           $GLOBALS['core']->callBehavior('adminPageHelpBlock',$args); 
    372  
    373357          if (empty($args)) { 
    374358               return; 
     
    476460          self::jsVar('dotclear.msg.confirm_delete_post', 
    477461               __("Are you sure you want to delete this entry?")). 
    478           self::jsVar('dotclear.msg.click_to_unlock', 
    479                __("Click here to unlock the field")). 
    480462          self::jsVar('dotclear.msg.confirm_spam_delete', 
    481463               __('Are you sure you want to delete all spams?')). 
     
    527509     { 
    528510          return 
    529           '<!--[if lt IE 9]>'."\n". 
    530           self::jsLoad('js/ie7/IE9.js'). 
     511          '<!--[if lt IE 8]>'."\n". 
     512          self::jsLoad('js/ie7/IE8.js'). 
    531513          '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n". 
    532514          '<![endif]-->'."\n"; 
     
    730712     '<link rel="stylesheet" type="text/css" href="style/jsUpload/style.css" />'."\n". 
    731713 
     714     '<script id="template-upload" type="text/x-tmpl"> 
     715     {% for (var i=0, file; file=o.files[i]; i++) { %} 
     716     <div class="template-upload fade"> 
     717     <div class="upload-file"> 
     718     <div class="upload-fileinfo"> 
     719          <span class="upload-filename">{%=file.name%}</span> 
     720          <span class="upload-filesize">({%=o.formatFileSize(file.size)%})</span> 
     721          <span class="upload-filecancel cancel">'.__('Cancel').'</span> 
     722          {% if (!o.files.error && !i && !o.options.autoUpload) { %} 
     723          <input type="submit" class="button start"  value="'.__('Send').'"/> 
     724          {% } %} 
     725          <span class="upload-filemsg"></span> 
     726     </div> 
     727     {% if (!o.files.error) { %} 
     728     <div class="upload-progress progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div> 
     729     {% } %} 
     730     </div> 
     731     {% } %} 
     732     </script> 
     733     <!-- The template to display files available for download --> 
     734     <script id="template-download" type="text/x-tmpl"> 
     735     {% for (var i=0, file; file=o.files[i]; i++) { %} 
     736     <div class="template-download fade"> 
     737     <div class="upload-file"> 
     738     <div class="upload-fileinfo"> 
     739          <span class="upload-filename">{%=file.name%}</span> 
     740          <span class="upload-filesize">({%=o.formatFileSize(file.size)%})</span> 
     741          <span class="upload-filemsg{% if (file.error) { %} upload-error{% } %}"> 
     742          {% if (file.error) { %} 
     743          '.__('Error:').' {%=file.error%} 
     744          {% } else { %} 
     745          '.__('File successfully uploaded.').' 
     746          {% } %} 
     747          </span> 
     748     </div> 
     749     <div class="upload-progress"> 
     750          {% if (!file.error) { %} 
     751          <div class="bar" style="width:100%;">100%</div> 
     752          {% } %} 
     753     </div> 
     754     </div> 
     755     {% } %} 
     756     </script>'. 
     757 
     758     self::jsLoad('js/jsUpload/vendor/jquery.ui.widget.js'). 
     759     self::jsLoad('js/jsUpload/tmpl.js'). 
     760     self::jsLoad('js/jsUpload/load-image.js'). 
     761     self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). 
     762     self::jsLoad('js/jsUpload/jquery.fileupload.js'). 
     763     self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). 
     764     self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). 
     765     self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'). 
     766 
    732767     '<script type="text/javascript">'."\n". 
    733768     "//<![CDATA[\n". 
     
    746781     self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). 
    747782     self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). 
    748      self::jsVar('dotclear.jsUpload.msg.send',__('Send')). 
    749      self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')). 
    750783     self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). 
    751784     self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). 
     
    754787     self::jsVar('dotclear.jsUpload.base_url',$base_url). 
    755788     "\n//]]>\n". 
    756      "</script>\n". 
    757  
    758      self::jsLoad('js/jsUpload/vendor/jquery.ui.widget.js'). 
    759      self::jsLoad('js/jsUpload/tmpl.js'). 
    760      self::jsLoad('js/jsUpload/template-upload.js'). 
    761      self::jsLoad('js/jsUpload/template-download.js'). 
    762      self::jsLoad('js/jsUpload/load-image.js'). 
    763      self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). 
    764      self::jsLoad('js/jsUpload/jquery.fileupload.js'). 
    765      self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). 
    766      self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). 
    767      self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'); 
     789     "</script>\n"; 
    768790} 
    769791 
  • inc/admin/prepend.php

    r1337 r1490  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    286286     $_menu['System']->title = __('System settings'); 
    287287     $_menu['Blog']->title = __('Blog'); 
    288      $_menu['Plugins']->title = __('Plugins'); 
     288     $_menu['Plugins']->title = __('Additional plugins'); 
    289289     if (!$user_ui_nofavmenu) 
    290290          $_menu['Favorites']->title = __('My favorites'); 
     
    375375     } 
    376376} 
     377 
     378# Add admin default templates path 
     379$core->tpl->getLoader()->addPath(dirname(__FILE__).'/default-templates'); 
     380# Set admin context 
     381$_ctx = new dcAdminContext($core); 
     382$core->tpl->addExtension($_ctx); 
     383 
     384# --BEHAVIOR-- adminPrepend 
     385$core->callBehavior('adminPrepend',$core,$_ctx); 
    377386?> 
  • inc/core/class.dc.blog.php

    r1353 r1490  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    8181               $this->desc = $b->blog_desc; 
    8282               $this->url = $b->blog_url; 
    83                $this->host = http::getHostFromURL($this->url); 
     83               $this->host = preg_replace('|^([a-z]{3,}://)(.*?)/.*$|','$1$2',$this->url); 
    8484               $this->creadt = strtotime($b->blog_creadt); 
    8585               $this->upddt = strtotime($b->blog_upddt); 
     
    9191               $this->public_path = path::fullFromRoot($this->settings->system->public_path,DC_ROOT); 
    9292                
    93                $this->post_status['-2'] = __('Pending'); 
    94                $this->post_status['-1'] = __('Scheduled'); 
    95                $this->post_status['0'] = __('Unpublished'); 
    96                $this->post_status['1'] = __('Published'); 
    97                 
    98                $this->comment_status['-2'] = __('Junk'); 
    99                $this->comment_status['-1'] = __('Pending'); 
    100                $this->comment_status['0'] = __('Unpublished'); 
    101                $this->comment_status['1'] = __('Published'); 
     93               $this->post_status['-2'] = __('pending'); 
     94               $this->post_status['-1'] = __('scheduled'); 
     95               $this->post_status['0'] = __('unpublished'); 
     96               $this->post_status['1'] = __('published'); 
     97                
     98               $this->comment_status['-2'] = __('junk'); 
     99               $this->comment_status['-1'] = __('pending'); 
     100               $this->comment_status['0'] = __('unpublished'); 
     101               $this->comment_status['1'] = __('published'); 
    102102                
    103103               # --BEHAVIOR-- coreBlogConstruct 
     
    805805           
    806806          if (!empty($params['user_id'])) { 
    807                $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."' "; 
     807               $strReq .= "AND U.user_id ".$this->con->in($params['user_id'])." "; 
    808808          } 
    809809           
     
    889889                    $strReq .= 'ORDER BY post_dt DESC '; 
    890890               } 
    891           } 
    892            
    893           if (!$count_only && !empty($params['limit'])) { 
    894                $strReq .= $this->con->limit($params['limit']); 
     891               if (!empty($params['limit'])) { 
     892                    $strReq .= $this->con->limit($params['limit']); 
     893               } 
    895894          } 
    896895           
  • plugins/aboutConfig/index.php

    r1358 r1490  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1212if (!defined('DC_CONTEXT_ADMIN')) { return; } 
    1313 
    14 # Local navigation 
    15 if (!empty($_POST['gs_nav'])) { 
    16      http::redirect($p_url.$_POST['gs_nav']); 
    17      exit; 
    18 } 
    19 if (!empty($_POST['ls_nav'])) { 
    20      http::redirect($p_url.$_POST['ls_nav']); 
    21      exit; 
    22 } 
    23  
    24 # Local settings update 
    25 if (!empty($_POST['s']) && is_array($_POST['s'])) 
     14class adminPageAboutConfig 
    2615{ 
    27      try 
     16     public static $p_url = 'plugin.php?p=aboutConfig'; 
     17      
     18     # Update local settings 
     19     public static function updLocal($form) 
    2820     { 
    29           foreach ($_POST['s'] as $ns => $s) 
    30           { 
    31                $core->blog->settings->addNamespace($ns); 
     21          self::updSettings($form); 
     22     } 
     23      
     24     # Update global settings 
     25     public static function updGlobal($form) 
     26     { 
     27          self::updSettings($form,true); 
     28     } 
     29      
     30     # Update settings 
     31     protected static function updSettings($form,$global=false) 
     32     { 
     33          global $core,$_ctx; 
     34           
     35          $part = $global ? 'global' : 'local'; 
     36          $prefix = $part.'_'; 
     37           
     38          try { 
     39               foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { 
     40                    $core->blog->settings->addNamespace($ns); 
     41                    $ns_settings = $global ?  
     42                         $namespace->dumpGlobalSettings() : $namespace->dumpSettings(); 
     43                     
     44                    foreach ($ns_settings as $k => $v) { 
     45                         // need to cast type 
     46                         $f = (string) $form->{$prefix.$ns.'_'.$k}; 
     47                         settype($f,$v['type']); 
     48                          
     49                         $core->blog->settings->$ns->put($k,$f,null,null,true,$global); 
     50                         $form->{$prefix.$ns.'_'.$k} = $f; 
     51                    } 
     52               } 
     53               $core->blog->triggerBlog(); 
    3254                
    33                foreach ($s as $k => $v)      { 
    34                     $core->blog->settings->$ns->put($k,$v); 
    35                } 
    36                 
    37                $core->blog->triggerBlog(); 
     55               http::redirect(self::$p_url.'&upd=1&part='.$part); 
     56          } 
     57          catch (Exception $e) { 
     58               $_ctx->addError($e->getMessage()); 
     59          } 
     60     } 
     61      
     62     # Set nav and settings forms 
     63     public static function setForms($global=false) 
     64     { 
     65          global $core, $_ctx; 
     66           
     67          $prefix = $global ? 'global_' : 'local_'; 
     68          $action = $global ? 'updGlobal' : 'updLocal'; 
     69           
     70          if (!empty($_POST[$prefix.'nav'])) { 
     71               http::redirect(self::$p_url.$_POST[$prefix.'nav']); 
     72               exit; 
    3873          } 
    3974           
    40           http::redirect($p_url.'&upd=1'); 
    41      } 
    42      catch (Exception $e) 
    43      { 
    44           $core->error->add($e->getMessage()); 
     75          $nav_form = new dcForm($core,$prefix.'nav_form','plugin.php'); 
     76          $settings_form = new dcForm($core,$prefix.'settings_form','plugin.php'); 
     77           
     78          $settings = $combo = array(); 
     79          foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { 
     80               $ns_settings = $global ?  
     81                    $namespace->dumpGlobalSettings() : $namespace->dumpSettings(); 
     82                
     83               foreach ($ns_settings as $k => $v) { 
     84                    $settings[$ns][$k] = $v; 
     85               } 
     86          } 
     87           
     88          ksort($settings); 
     89          foreach ($settings as $ns => $s) { 
     90               $combo['#'.$prefix.$ns] = $ns; 
     91               ksort($s); 
     92               foreach ($s as $k => $v) { 
     93                    if ($v['type'] == 'boolean') { 
     94                         $settings_form->addField( 
     95                              new dcFieldCombo($prefix.$ns.'_'.$k, 
     96                                   '',array(1 => __('yes'),0 => __('no')))); 
     97                    } 
     98                    else { 
     99                         $settings_form->addField( 
     100                              new dcFieldText($prefix.$ns.'_'.$k,'')); 
     101                    } 
     102                    $settings_form->{$prefix.$ns.'_'.$k} = $v['value']; 
     103               } 
     104          } 
     105           
     106          $nav_form 
     107               ->addField( 
     108                    new dcFieldCombo($prefix.'nav','',$combo,array( 
     109                         "label" => __('Goto:')))) 
     110               ->addField( 
     111                    new dcFieldSubmit($prefix.'nav_submit',__('OK'))) 
     112               ->addField( 
     113                    new dcFieldHidden ('p','aboutConfig')) 
     114               ; 
     115           
     116          $settings_form 
     117               ->addField( 
     118                    new dcFieldSubmit($prefix.'submit',__('Save'),array( 
     119                         'action' => array('adminPageAboutConfig',$action)))) 
     120               ->addField( 
     121                    new dcFieldHidden ('p','aboutConfig')) 
     122               ; 
     123           
     124          $_ctx->{$prefix.'settings'} = $settings; 
     125           
     126          $nav_form->setup(); 
     127          $settings_form->setup(); 
    45128     } 
    46129} 
    47130 
    48 # Global settings update 
    49 if (!empty($_POST['gs']) && is_array($_POST['gs'])) 
    50 { 
    51      try 
    52      { 
    53           foreach ($_POST['gs'] as $ns => $s) 
    54           { 
    55                $core->blog->settings->addNamespace($ns); 
    56                 
    57                foreach ($s as $k => $v)      { 
    58                     $core->blog->settings->$ns->put($k,$v,null,null,true,true); 
    59                } 
    60                 
    61                $core->blog->triggerBlog(); 
    62           } 
    63            
    64           http::redirect($p_url.'&upd=1&part=global'); 
    65      } 
    66      catch (Exception $e) 
    67      { 
    68           $core->error->add($e->getMessage()); 
    69      } 
     131# Local settings forms 
     132adminPageAboutConfig::setForms(); 
     133 
     134# Global settings forms 
     135adminPageAboutConfig::setForms(true); 
     136 
     137# Commons 
     138if (!empty($_GET['upd'])) { 
     139     $_ctx->setAlert(__('Configuration successfully updated')); 
    70140} 
    71  
    72 $part = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local'; 
    73  
    74 function settingLine($id,$s,$ns,$field_name,$strong_label) 
    75 { 
    76      if ($s['type'] == 'boolean') { 
    77           $field = form::combo(array($field_name.'['.$ns.']['.$id.']',$field_name.'_'.$id), 
    78           array(__('yes') => 1, __('no') => 0),$s['value'] ? 1 : 0); 
    79      } else { 
    80           $field = form::field(array($field_name.'['.$ns.']['.$id.']',$field_name.'_'.$id),40,null, 
    81           html::escapeHTML($s['value'])); 
    82      } 
    83       
    84      $slabel = $strong_label ? '<strong>%s</strong>' : '%s'; 
    85       
    86      return 
    87      '<tr class="line">'. 
    88      '<td scope="raw"><label for="s_'.$id.'">'.sprintf($slabel,html::escapeHTML($id)).'</label></td>'. 
    89      '<td>'.$field.'</td>'. 
    90      '<td>'.$s['type'].'</td>'. 
    91      '<td>'.html::escapeHTML($s['label']).'</td>'. 
    92      '</tr>'; 
     141if (!empty($_GET['upda'])) { 
     142     $_ctx->setAlert(__('Settings definition successfully updated')); 
    93143} 
     144$_ctx->default_tab = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local'; 
     145$_ctx->setBreadCrumb('about:config'); 
     146$core->tpl->display('@aboutConfig/index.html.twig'); 
    94147?> 
    95 <html> 
    96 <head> 
    97   <title>about:config</title> 
    98   <?php echo dcPage::jsPageTabs($part); ?> 
    99   <script type="text/javascript"> 
    100      //<![CDATA[ 
    101      $(function() { 
    102           $("#gs_submit").hide(); 
    103           $("#ls_submit").hide(); 
    104           $("#gs_nav").change(function() { 
    105                window.location = $("#gs_nav option:selected").val(); 
    106           }) 
    107           $("#ls_nav").change(function() { 
    108                window.location = $("#ls_nav option:selected").val(); 
    109           }) 
    110      }); 
    111      //]]> 
    112      </script> 
    113 </head> 
    114  
    115 <body> 
    116 <?php 
    117 echo dcPage::breadcrumb( 
    118      array( 
    119           __('System') => '', 
    120           html::escapeHTML($core->blog->name) => '', 
    121           '<span class="page-title">'.__('about:config').'</span>' => '' 
    122      )); 
    123 if (!empty($_GET['upd'])) { 
    124      dcPage::message(__('Configuration successfully updated')); 
    125 } 
    126  
    127 if (!empty($_GET['upda'])) { 
    128      dcPage::message(__('Settings definition successfully updated')); 
    129 } 
    130 ?> 
    131  
    132 <div id="local" class="multi-part" title="<?php echo sprintf(__('Settings for %s'),html::escapeHTML($core->blog->name)); ?>"> 
    133  
    134  
    135 <?php 
    136 $table_header = '<table class="settings" id="%s"><caption class="as_h3">%s</caption>'. 
    137 '<thead>'. 
    138 '<tr>'."\n". 
    139 '  <th class="nowrap">Setting ID</th>'."\n". 
    140 '  <th>'.__('Value').'</th>'."\n". 
    141 '  <th>'.__('Type').'</th>'."\n". 
    142 '  <th class="maximalx">'.__('Description').'</th>'."\n". 
    143 '</tr>'."\n". 
    144 '</thead>'."\n". 
    145 '<tbody>'; 
    146 $table_footer = '</tbody></table>'; 
    147  
    148 $settings = array(); 
    149 foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { 
    150      foreach ($namespace->dumpSettings() as $k => $v) { 
    151           $settings[$ns][$k] = $v; 
    152      } 
    153 } 
    154 ksort($settings); 
    155 if (count($settings) > 0) { 
    156      $ns_combo = array(); 
    157      foreach ($settings as $ns => $s) { 
    158           $ns_combo[$ns] = '#l_'.$ns; 
    159      } 
    160      echo  
    161           '<form action="plugin.php" method="post">'. 
    162           '<p class="anchor-nav">'. 
    163           '<label for="ls_nav" class="classic">'.__('Goto:').'</label> '.form::combo('ls_nav',$ns_combo). 
    164           ' <input type="submit" value="'.__('Ok').'" id="ls_submit" />'. 
    165           '<input type="hidden" name="p" value="aboutConfig" />'. 
    166           $core->formNonce().'</p></form>'; 
    167 } 
    168 ?> 
    169  
    170 <form action="plugin.php" method="post"> 
    171  
    172 <?php 
    173 foreach ($settings as $ns => $s) 
    174 { 
    175      ksort($s); 
    176      echo sprintf($table_header,'l_'.$ns,$ns); 
    177      foreach ($s as $k => $v) 
    178      { 
    179           echo settingLine($k,$v,$ns,'s',!$v['global']); 
    180      } 
    181      echo $table_footer; 
    182 } 
    183 ?> 
    184  
    185 <p><input type="submit" value="<?php echo __('Save'); ?>" /> 
    186 <input type="hidden" name="p" value="aboutConfig" /> 
    187 <?php echo $core->formNonce(); ?></p> 
    188 </form> 
    189 </div> 
    190  
    191 <div id="global" class="multi-part" title="<?php echo __('global settings'); ?>"> 
    192  
    193 <?php 
    194 $settings = array(); 
    195  
    196 foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { 
    197      foreach ($namespace->dumpGlobalSettings() as $k => $v) { 
    198           $settings[$ns][$k] = $v; 
    199      } 
    200 } 
    201  
    202 ksort($settings); 
    203  
    204 if (count($settings) > 0) { 
    205      $ns_combo = array(); 
    206      foreach ($settings as $ns => $s) { 
    207           $ns_combo[$ns] = '#g_'.$ns; 
    208      } 
    209      echo  
    210           '<form action="plugin.php" method="post">'. 
    211           '<p class="anchor-nav">'. 
    212           '<label for="gs_nav" class="classic">'.__('Goto:').'</label> '.form::combo('gs_nav',$ns_combo). 
    213           ' <input type="submit" value="'.__('Ok').'" id="gs_submit" />'. 
    214           '<input type="hidden" name="p" value="aboutConfig" />'. 
    215           $core->formNonce().'</p></form>'; 
    216 } 
    217 ?> 
    218  
    219 <form action="plugin.php" method="post"> 
    220  
    221 <?php 
    222 foreach ($settings as $ns => $s) 
    223 { 
    224      ksort($s); 
    225      echo sprintf($table_header,'g_'.$ns,$ns); 
    226      foreach ($s as $k => $v) 
    227      { 
    228           echo settingLine($k,$v,$ns,'gs',false); 
    229      } 
    230      echo $table_footer; 
    231 } 
    232 ?> 
    233  
    234 <p><input type="submit" value="<?php echo __('Save'); ?>" /> 
    235 <input type="hidden" name="p" value="aboutConfig" /> 
    236 <?php echo $core->formNonce(); ?></p> 
    237 </form> 
    238 </div> 
    239  
    240 </body> 
    241 </html> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map