Dotclear

Changeset 2715:a87ddf7dbfb5


Ignore:
Timestamp:
05/20/14 08:39:33 (11 years ago)
Author:
Dsls
Branch:
twig
Parents:
2683:fb8aa74332f1 (diff), 2714:eed2e5727277 (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:

Merge with default (admin/post.php still to update with editor preferences, in twig template)

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • admin/index.php

    r2708 r2715  
    1515     exit; 
    1616} 
     17if (!empty($_GET['tf'])) { 
     18     define('DC_CONTEXT_ADMIN',true); 
     19     require dirname(__FILE__).'/../inc/load_theme_file.php'; 
     20     exit; 
     21} 
    1722 
    1823require dirname(__FILE__).'/../inc/admin/prepend.php'; 
     
    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)) { 
    61           $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean','',null,true); 
    62      } 
    63      $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean'); 
    64 } 
    65  
    66 // Handle folded/unfolded sections in admin from user preferences 
    67 $ws = $core->auth->user_prefs->addWorkspace('toggles'); 
    68 if (!$core->auth->user_prefs->toggles->prefExists('unfolded_sections')) { 
    69      $core->auth->user_prefs->toggles->put('unfolded_sections','','string','Folded sections in admin',null,true); 
    70 } 
    71  
     134          $core->auth->user_prefs->dashboard->put('quickentry',true,'boolean','',null,true); 
     135     } 
     136     $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; 
     188} 
    72189 
    73190# Dashboard icons 
     
    76193$favs = $core->favs->getUserFavorites(); 
    77194$core->favs->appendDashboardIcons($__dashboard_icons); 
     195 
    78196 
    79197# Check plugins and themes update from repository 
     
    101219 
    102220$dashboardItem = 0; 
     221 
    103222 
    104223if ($core->auth->user_prefs->dashboard->dcnews) { 
     
    168287$core->callBehavior('adminDashboardContents', $core, $__dashboard_contents); 
    169288 
    170 /* DISPLAY 
    171 -------------------------------------------------------- */ 
    172 dcPage::open(__('Dashboard'), 
    173      dcPage::jsLoad('js/_index.js'). 
    174      $core->callBehavior('adminPostEditor'). 
    175      # --BEHAVIOR-- adminDashboardHeaders 
    176      $core->callBehavior('adminDashboardHeaders'), 
    177      dcPage::breadcrumb( 
    178           array( 
    179           __('Dashboard').' : '.html::escapeHTML($core->blog->name) => '' 
    180           ), 
    181           array('home_link' =>false) 
    182      ) 
    183 ); 
    184  
    185 # Dotclear updates notifications 
    186 if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) 
    187 { 
    188      $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 
    189      $new_v = $updater->check(DC_VERSION); 
    190      $version_info = $new_v ? $updater->getInfoURL() : ''; 
    191  
    192      if ($updater->getNotify() && $new_v) { 
    193           echo 
    194           '<div class="dc-update"><h3>'.sprintf(__('Dotclear %s is available!'),$new_v).'</h3> '. 
    195           '<p><a class="button submit" href="update.php">'.sprintf(__('Upgrade now'),$new_v).'</a> '. 
    196           '<a class="button" href="update.php?hide_msg=1">'.__('Remind me later').'</a>'. 
    197           ($version_info ? ' </p>'. 
    198           '<p class="updt-info"><a href="'.$version_info.'">'.__('Information about this version').'</a>' : '').'</p>'. 
    199           '</div>'; 
    200      } 
    201 } 
    202  
    203 if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->getBlogCount() > 1) { 
    204      echo 
    205      '<p><a href="index.php?default_blog=1" class="button">'.__('Make this blog my default blog').'</a></p>'; 
    206 } 
    207  
     289# Blog status message 
    208290if ($core->blog->status == 0) { 
    209      echo '<p class="static-msg">'.__('This blog is offline').'.</p>'; 
     291     $_ctx->addMessageStatic(__('This blog is offline')); 
    210292} elseif ($core->blog->status == -1) { 
    211      echo '<p class="static-msg">'.__('This blog is removed').'.</p>'; 
    212 } 
    213  
     293     $_ctx->addMessageStatic(__('This blog is removed')); 
     294} 
     295 
     296# Config errors messages 
    214297if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) { 
    215      echo 
    216      '<p class="static-msg">'. 
    217      sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL'). 
    218      ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 
    219      '</p>'; 
    220 } 
    221  
     298     $_ctx->addMessageStatic( 
     299          sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL').' '. 
     300          __('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.') 
     301     ); 
     302} 
    222303if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) { 
    223      echo 
    224      '<p class="static-msg">'. 
    225      sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM'). 
    226      ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 
    227      '</p>'; 
    228 } 
    229  
    230 $err = array(); 
    231  
    232 # Check cache directory 
    233 if ( $core->auth->isSuperAdmin() ) { 
    234      if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) { 
    235           $err[] = '<p>'.__("The cache directory does not exist or is not writable. You must create this directory with sufficient rights and affect this location to \"DC_TPL_CACHE\" in inc/config.php file.").'</p>'; 
    236      } 
    237 } else { 
    238      if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) { 
    239           $err[] = '<p>'.__("The cache directory does not exist or is not writable. You should contact your administrator.").'</p>'; 
    240      } 
    241 } 
    242  
    243 # Check public directory 
    244 if ( $core->auth->isSuperAdmin() ) { 
    245      if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) { 
    246           $err[] = '<p>'.__("There is no writable directory /public/ at the location set in about:config \"public_path\". You must create this directory with sufficient rights (or change this setting).").'</p>'; 
    247      } 
    248 } else { 
    249      if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) { 
    250           $err[] = '<p>'.__("There is no writable root directory for the media manager. You should contact your administrator.").'</p>'; 
    251      } 
    252 } 
    253  
    254 # Error list 
    255 if (count($err) > 0) { 
    256      echo '<div class="error"><p><strong>'.__('Error:').'</strong></p>'. 
    257      '<ul><li>'.implode("</li><li>",$err).'</li></ul></div>'; 
    258 } 
    259  
    260 # Plugins install messages 
    261 if (!empty($plugins_install['success'])) 
    262 { 
    263      echo '<div class="success">'.__('Following plugins have been installed:').'<ul>'; 
    264      foreach ($plugins_install['success'] as $k => $v) { 
    265           echo '<li>'.$k.'</li>'; 
    266      } 
    267      echo '</ul></div>'; 
    268 } 
    269 if (!empty($plugins_install['failure'])) 
    270 { 
    271      echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 
    272      foreach ($plugins_install['failure'] as $k => $v) { 
    273           echo '<li>'.$k.' ('.$v.')</li>'; 
    274      } 
    275      echo '</ul></div>'; 
    276 } 
    277 # Errors modules notifications 
    278 if ($core->auth->isSuperAdmin()) 
    279 { 
    280      $list = $core->plugins->getErrors(); 
    281      if (!empty($list)) { 
    282           echo 
    283           '<div class="error" id="module-errors" class="error"><p>'.__('Errors have occured with following plugins:').'</p> '. 
    284           '<ul><li>'.implode("</li>\n<li>", $list).'</li></ul></div>'; 
    285      } 
    286 } 
    287  
    288 # Dashboard columns (processed first, as we need to know the result before displaying the icons.) 
    289 $dashboardItems = ''; 
    290  
    291 foreach ($__dashboard_items as $i) 
    292 { 
    293      if ($i->count() > 0) 
    294      { 
    295           $dashboardItems .= ''; 
    296           foreach ($i as $v) { 
    297                $dashboardItems .= $v; 
    298           } 
    299           $dashboardItems .= ''; 
    300      } 
    301 } 
    302  
    303 # Dashboard elements 
    304 echo '<div id="dashboard-main">'; 
    305  
    306 # Dashboard icons 
    307 echo '<div id="icons">'; 
    308 foreach ($__dashboard_icons as $i) 
    309 { 
    310      echo 
    311      '<p><a href="'.$i[1].'"><img src="'.dc_admin_icon_url($i[2]).'" alt="" />'. 
    312      '<br /><span>'.$i[0].'</span></a></p>'; 
    313 } 
    314 echo '</div>'; 
    315  
    316 if ($core->auth->user_prefs->dashboard->quickentry) { 
    317      if ($core->auth->check('usage,contentadmin',$core->blog->id)) 
    318      { 
    319           # Getting categories 
    320           $categories_combo = dcAdminCombos::getCategoriesCombo( 
    321                $core->blog->getCategories(array('post_type'=>'post')) 
    322           ); 
    323  
    324           echo 
    325           '<div id="quick">'. 
    326           '<h3>'.__('Quick entry').'</h3>'. 
    327           '<form id="quick-entry" action="'.$core->adminurl->get('admin.post').'" method="post" class="fieldset">'. 
    328           '<h4>'.__('New entry').'</h4>'. 
    329           '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 
    330           form::field('post_title',20,255,'','maximal'). 
    331           '</p>'. 
    332           '<p class="area"><label class="required" '. 
    333           'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 
    334           form::textarea('post_content',50,10). 
    335           '</p>'. 
    336           '<p><label for="cat_id" class="classic">'.__('Category:').'</label> '. 
    337           form::combo('cat_id',$categories_combo).'</p>'. 
    338           ($core->auth->check('categories', $core->blog->id) 
    339                ? '<div>'. 
    340                '<p id="new_cat" class="q-cat">'.__('Add a new category').'</p>'. 
    341                '<p class="q-cat"><label for="new_cat_title">'.__('Title:').'</label> '. 
    342                form::field('new_cat_title',30,255,'','').'</p>'. 
    343                '<p class="q-cat"><label for="new_cat_parent">'.__('Parent:').'</label> '. 
    344                form::combo('new_cat_parent',$categories_combo,'',''). 
    345                '</p>'. 
    346                '<p class="form-note info clear">'.__('This category will be created when you will save your post.').'</p>'. 
    347                '</div>' 
    348                : ''). 
    349           '<p><input type="submit" value="'.__('Save').'" name="save" /> '. 
    350           ($core->auth->check('publish',$core->blog->id) 
    351                ? '<input type="hidden" value="'.__('Save and publish').'" name="save-publish" />' 
    352                : ''). 
    353           $core->formNonce(). 
    354           form::hidden('post_status',-2). 
    355           form::hidden('post_format',$core->auth->getOption('post_format')). 
    356           form::hidden('post_excerpt',''). 
    357           form::hidden('post_lang',$core->auth->getInfo('user_lang')). 
    358           form::hidden('post_notes',''). 
    359           '</p>'. 
    360           '</form>'. 
    361           '</div>'; 
    362      } 
    363 } 
    364  
    365 foreach ($__dashboard_contents as $i) 
    366 { 
    367      if ($i->count() > 0) 
    368      { 
    369           $dashboardContents .= ''; 
    370           foreach ($i as $v) { 
    371                $dashboardContents .= $v; 
    372           } 
    373           $dashboardContents .= ''; 
    374      } 
    375 } 
    376  
    377 if ($dashboardContents != '' || $dashboardItems != '') { 
    378      echo 
    379      '<div id="dashboard-boxes">'. 
    380      '<div class="db-items">'.$dashboardItems.$dashboardContents.'</div>'. 
    381      '</div>'; 
    382 } 
    383  
    384 echo '</div>'; #end dashboard-main 
    385 dcPage::helpBlock('core_dashboard'); 
    386 dcPage::close(); 
     304     $_ctx->addMessageStatic( 
     305          sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM').' '. 
     306          __('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.') 
     307     ); 
     308} 
     309$_ctx->dashboard_icons = $__dashboard_icons; 
     310//print_r($__dashboard_icons);exit; 
     311$_ctx->setBreadCrumb(__('Dashboard').' : '.html::escapeHTML($core->blog->name), false); 
     312$core->tpl->display('index.html.twig'); 
     313?> 
  • admin/plugin.php

    r2593 r2715  
    3535      
    3636     $p_info = $core->plugins->getModules($p); 
     37     $p_name = $p; 
    3738     $p_url = 'plugin.php?p='.$p; 
    3839     $p_title = $p_head = $p_content = ''; 
  • admin/plugin.php

    r2708 r2715  
    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_name = $p; 
    3938     $p_url = 'plugin.php?p='.$p; 
    40  
    41      $p_title = 'no content - plugin'; 
    42      $p_head = ''; 
    43      $p_content = '<p>'.__('No content found on this plugin.').'</p>'; 
    44  
     39     $p_title = $p_head = $p_content = ''; 
     40//*/  
     41     # Get page content 
    4542     ob_start(); 
    4643     include $p_file; 
     
    4845     ob_end_clean(); 
    4946 
    50      if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { 
    51           if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { 
    52                $p_title = $mt[1]; 
    53           } 
    54  
    55           if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { 
    56                foreach ($ms[1] as $v) { 
    57                     $p_head .= $v."\n"; 
     47     # Check context and display 
     48     if ($_ctx->hasPageTitle() && !empty($res)) { 
     49          $has_content = true; 
     50          echo $res; 
     51     } 
     52//* Keep this for old style plugins using dcPage 
     53     elseif (!$_ctx->hasPageTitle()) { 
     54           
     55          if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { 
     56               if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { 
     57                    $p_title = $mt[1]; 
     58               } 
     59                
     60               if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { 
     61                    foreach ($ms[1] as $v) { 
     62                         $p_head .= $v."\n"; 
     63                    } 
     64               } 
     65                
     66               if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { 
     67                    foreach ($ms[1] as $v) { 
     68                         $p_head .= $v."\n"; 
     69                    } 
     70               } 
     71                
     72               if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { 
     73                    foreach ($ms[1] as $v) { 
     74                         $p_head .= $v."\n"; 
     75                    } 
    5876               } 
    5977          } 
    60  
    61           if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { 
    62                foreach ($ms[1] as $v) { 
    63                     $p_head .= $v."\n"; 
    64                } 
    65           } 
    66  
    67           if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { 
    68                foreach ($ms[1] as $v) { 
    69                     $p_head .= $v."\n"; 
    70                } 
     78           
     79          if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { 
     80               $p_content = $m[1]; 
     81                
     82               call_user_func($open_f,$p_title,$p_head); 
     83               echo $p_content; 
     84               call_user_func($close_f); 
     85                
     86               $has_content = true; 
    7187          } 
    7288     } 
    73  
    74      if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { 
    75           $p_content = $m[1]; 
    76      } 
    77  
    78      call_user_func($open_f,$p_title,$p_head); 
    79      echo $p_content; 
    80      call_user_func($close_f); 
     89//*/ 
    8190} 
    82 else 
    83 { 
    84      call_user_func($open_f,__('Plugin not found'),'', 
    85           dcPage::breadcrumb( 
    86                array( 
    87                     __('System') => '', 
    88                     __('Plugin not found') => '' 
    89                )) 
    90      ); 
    91  
    92      echo '<p>'.__('The plugin you reached does not exist or does not have an admin page.').'</p>'; 
    93  
    94      call_user_func($close_f); 
     91# No plugin or content found 
     92if (!$has_content) { 
     93     $_ctx->setBreadcrumb(__('Plugin not found')); 
     94     $_ctx->addError(__('The plugin you reached does not exist or does not have an admin page.')); 
     95     $core->tpl->display('plugin.html.twig'); 
    9596} 
     97?> 
  • admin/post.php

    r2711 r2715  
    1515dcPage::check('usage,contentadmin'); 
    1616 
    17 $post_id = ''; 
    18 $cat_id = ''; 
    19 $post_dt = ''; 
    20 $post_format = $core->auth->getOption('post_format'); 
    21 $post_editor = $core->auth->getOption('editor'); 
    22 $post_password = ''; 
    23 $post_url = ''; 
    24 $post_lang = $core->auth->getInfo('user_lang'); 
    25 $post_title = ''; 
    26 $post_excerpt = ''; 
    27 $post_excerpt_xhtml = ''; 
    28 $post_content = ''; 
    29 $post_content_xhtml = ''; 
    30 $post_notes = ''; 
    31 $post_status = $core->auth->getInfo('user_post_status'); 
    32 $post_selected = false; 
    33 $post_open_comment = $core->blog->settings->system->allow_comments; 
    34 $post_open_tb = $core->blog->settings->system->allow_trackbacks; 
     17class PostActions  
     18{ 
     19     public static function savePost($form) { 
     20          global $_ctx, $core; 
     21          if (!$form->can_edit_post) { 
     22               return; 
     23          } 
     24          try { 
     25               $form->check($_ctx); 
     26               $form->cat_id = (integer) $form->cat_id; 
     27      
     28               if (!empty($form->post_dt)) { 
     29                    try 
     30                    { 
     31                         $post_dt = strtotime($form->post_dt); 
     32                         if ($post_dt == false || $post_dt == -1) { 
     33                              $bad_dt = true; 
     34                              throw new Exception(__('Invalid publication date')); 
     35                         } 
     36                         $form->post_dt = date('Y-m-d H:i',$post_dt); 
     37                    } 
     38                    catch (Exception $e) 
     39                    { 
     40                         $core->error->add($e->getMessage()); 
     41                    } 
     42               } 
     43               $post_excerpt = $form->post_excerpt; 
     44               $post_content = $form->post_content; 
     45               $post_excerpt_xhtml = ''; 
     46               $post_content_xhtml = ''; 
     47               $core->blog->setPostContent( 
     48                    $form->id,$form->post_format,$form->post_lang, 
     49                    $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml 
     50               ); 
     51               $form->post_excerpt = $post_excerpt; 
     52               $form->post_content = $post_content; 
     53               $form->post_excerpt_xhtml = $post_excerpt_xhtml; 
     54               $form->post_content_xhtml = $post_content_xhtml; 
     55                
     56               $cur = $core->con->openCursor($core->prefix.'post'); 
     57      
     58               $cur->post_title = $form->post_title; 
     59               $cur->cat_id = $form->cat_id ? $form->cat_id : null; 
     60               $cur->post_dt = $form->post_dt ? date('Y-m-d H:i:00',strtotime($form->post_dt)) : ''; 
     61               $cur->post_format = $form->post_format; 
     62               $cur->post_password = $form->post_password; 
     63               $cur->post_lang = $form->post_lang; 
     64               $cur->post_title = $form->post_title; 
     65               $cur->post_excerpt = $form->post_excerpt; 
     66               $cur->post_excerpt_xhtml = $form->post_excerpt_xhtml; 
     67               $cur->post_content = $form->post_content; 
     68               $cur->post_content_xhtml = $form->post_content_xhtml; 
     69               $cur->post_notes = $form->post_notes; 
     70               $cur->post_status = $form->post_status; 
     71               $cur->post_selected = (integer) $form->post_selected; 
     72               $cur->post_open_comment = (integer) $form->post_open_comment; 
     73               $cur->post_open_tb = (integer) $form->post_open_tb; 
     74      
     75               if (!empty($form->post_url)) { 
     76                    $cur->post_url = $form->post_url; 
     77               } 
     78      
     79               # Update post 
     80               if ($form->id) 
     81               { 
     82                    # --BEHAVIOR-- adminBeforePostUpdate 
     83                    $core->callBehavior('adminBeforePostUpdate',$cur,$form->id); 
     84                     
     85                    $core->blog->updPost($form->id,$cur); 
     86                     
     87                    # --BEHAVIOR-- adminAfterPostUpdate 
     88                    $core->callBehavior('adminAfterPostUpdate',$cur,$form->id); 
     89                    http::redirect('post.php?id='.$form->id.'&upd=1'); 
     90               } 
     91               else 
     92               { 
     93                    $cur->user_id = $core->auth->userID(); 
     94                                        # --BEHAVIOR-- adminBeforePostCreate 
     95                    $core->callBehavior('adminBeforePostCreate',$cur); 
     96                     
     97                    $return_id = $core->blog->addPost($cur); 
     98                     
     99                    # --BEHAVIOR-- adminAfterPostCreate 
     100                    $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 
     101                     
     102                    http::redirect('post.php?id='.$return_id.'&crea=1'); 
     103               } 
     104 
     105          } catch (Exception $e) { 
     106               $_ctx->addError($e->getMessage()); 
     107          } 
     108     } 
     109     public static function deletePost($form) { 
     110          global $core,$_ctx; 
     111          if ($form->can_delete) { 
     112               try { 
     113                    $post_id = $form->id; 
     114                    $core->callBehavior('adminBeforePostDelete',$post_id); 
     115                    $core->blog->delPost($post_id); 
     116                    http::redirect('posts.php'); 
     117                    exit; 
     118               } catch (Exception $e) { 
     119                    $_ctx->addError($e->getMessage()); 
     120               } 
     121          } 
     122     } 
     123} 
    35124 
    36125$page_title = __('New entry'); 
    37  
     126$post_id=''; 
    38127$can_view_page = true; 
    39128$can_edit_post = $core->auth->check('usage,contentadmin',$core->blog->id); 
     
    41130$can_delete = false; 
    42131 
    43 $post_headlink = '<link rel="%s" title="%s" href="'.$core->adminurl->get('admin.post',array('id' => "%s"),'&').'" />'; 
    44 $post_link = '<a href="'.$core->adminurl->get('admin.post',array('id' => "%s"),'&').'" title="%s">%s</a>'; 
     132$post_headlink = '<link rel="%s" title="%s" href="post.php?id=%s" />'; 
     133$post_link = '<a href="post.php?id=%s" title="%s">%s</a>'; 
    45134 
    46135$next_link = $prev_link = $next_headlink = $prev_headlink = null; 
     
    48137# If user can't publish 
    49138if (!$can_publish) { 
    50      $post_status = -2; 
     139     $form->post_status = -2; 
    51140} 
    52141 
    53142# Getting categories 
    54 $categories_combo = dcAdminCombos::getCategoriesCombo( 
    55      $core->blog->getCategories(array('post_type'=>'post')) 
    56 ); 
    57  
    58 $status_combo = dcAdminCombos::getPostStatusesCombo(); 
    59  
    60 $img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     143$categories_combo = array('&nbsp;' => ''); 
     144try { 
     145     $categories = $core->blog->getCategories(array('post_type'=>'post')); 
     146     while ($categories->fetch()) { 
     147          $categories_combo[$categories->cat_id] =  
     148               str_repeat('&nbsp;&nbsp;',$categories->level-1). 
     149               ($categories->level-1 == 0 ? '' : '&bull; '). 
     150               html::escapeHTML($categories->cat_title); 
     151     } 
     152} catch (Exception $e) { } 
     153 
     154# Status combo 
     155foreach ($core->blog->getAllPostStatus() as $k => $v) { 
     156     $status_combo[$k] = $v; 
     157} 
    61158 
    62159# Formaters combo 
    63 $formaters_combo = dcAdminCombos::getFormatersCombo(); 
    64 foreach ($formaters_combo as $editor => $formats) { 
    65      foreach ($formats as $format) { 
    66           $formaters_combo[$editor][$format] = "$editor:$format"; 
    67      } 
     160foreach ($core->getFormaters() as $v) { 
     161     $formaters_combo[$v] = $v; 
    68162} 
    69163 
    70164# Languages combo 
    71165$rs = $core->blog->getLangs(array('order'=>'asc')); 
    72 $lang_combo = dcAdminCombos::getLangsCombo($rs,true); 
    73  
    74 # Validation flag 
    75 $bad_dt = false; 
    76  
    77 # Trackbacks 
    78 $TB = new dcTrackback($core); 
    79 $tb_urls = $tb_excerpt = ''; 
    80  
    81 if (count($formaters_combo)==0 || !$core->auth->getOption('editor') || $core->auth->getOption('editor')=='') { 
    82      dcPage::addNotice("message",  
    83                            sprintf(__('Choose an active editor in %s.'),  
    84                                           '<a href="preferences.php#user-options">'.__('your preferences').'</a>' 
    85                                           ) 
    86                            ); 
    87 } 
    88  
     166$all_langs = l10n::getISOcodes(0,1); 
     167$lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(0,1)); 
     168while ($rs->fetch()) { 
     169     if (isset($all_langs[$rs->post_lang])) { 
     170          $lang_combo[__('Most used')][$rs->post_lang] = $all_langs[$rs->post_lang]; 
     171          unset($lang_combo[__('Available')][$rs->post_lang]); 
     172     } else { 
     173          $lang_combo[__('Most used')][$rs->post_lang] = $all_langs[$rs->post_lang]; 
     174     } 
     175} 
     176unset($all_langs); 
     177unset($rs); 
     178 
     179$form = new dcForm($core,'post','post.php'); 
     180$form 
     181     ->addField( 
     182          new dcFieldText('post_title','', array( 
     183               'maxlength'         => 255, 
     184               'required'     => true, 
     185               'label'        => __('Title:')))) 
     186     ->addField( 
     187          new dcFieldTextArea('post_excerpt','', array( 
     188               'cols'         => 50, 
     189               'rows'         => 5, 
     190               'label'        => __("Excerpt:").'<span class="form-note">'. 
     191               __('Add an introduction to the post.').'</span>'))) 
     192     ->addField( 
     193          new dcFieldTextArea('post_content','', array( 
     194               'required'     => true, 
     195               'label'        => __("Content:")))) 
     196     ->addField( 
     197          new dcFieldTextArea('post_notes','', array( 
     198               'label'        => __("Notes")))) 
     199     ->addField( 
     200          new dcFieldSubmit('save',__('Save'),array( 
     201               'action' => array('PostActions','savePost')))) 
     202     ->addField( 
     203          new dcFieldSubmit('delete',__('Delete'),array( 
     204               'action' => array('PostActions','deletePost')))) 
     205     ->addField( 
     206          new dcFieldCombo('post_status',$core->auth->getInfo('user_post_status'),$status_combo,array( 
     207               'disabled' => !$can_publish, 
     208               'label' => __('Entry status')))) 
     209     ->addField( 
     210          new dcFieldCombo('cat_id','',$categories_combo,array( 
     211               "label" => __('Category')))) 
     212     ->addField( 
     213          new dcFieldCombo('new_cat_parent','',$categories_combo,array( 
     214               "label" => __('Parent:')))) 
     215     ->addField( 
     216          new dcFieldText('new_cat_title','', array( 
     217               'maxlength'         => 255, 
     218               'label'        => __('Title')))) 
     219           
     220     ->addField( 
     221          new dcFieldText('post_dt','',array( 
     222               "label" => __('Publication date and hour')))) 
     223     ->addField( 
     224          new dcFieldCombo('post_format',$core->auth->getOption('post_format'),$formaters_combo,array( 
     225               "label" => __('Text formating')))) 
     226     ->addField( 
     227          new dcFieldCheckbox ('post_open_comment',$core->blog->settings->system->allow_comments,array( 
     228               "label" => __('Accept comments')))) 
     229     ->addField( 
     230          new dcFieldCheckbox ('post_open_tb',$core->blog->settings->system->allow_trackbacks,array( 
     231               "label" => __('Accept trackbacks')))) 
     232     ->addField( 
     233          new dcFieldCheckbox ('post_selected',array(1=>false),array( 
     234               "label" => __('Selected entry')))) 
     235     ->addField( 
     236          new dcFieldCombo ('post_lang',$core->auth->getInfo('user_lang'),$lang_combo, array( 
     237               "label" => __('Entry lang:')))) 
     238     ->addField( 
     239          new dcFieldText('post_password','',array( 
     240               "maxlength" => 32, 
     241               "label" => __('Entry password:')))) 
     242     ->addField( 
     243          new dcFieldText('post_url','',array( 
     244               "maxlength" => 255, 
     245               "label" => __('Basename:')))) 
     246     ->addField( 
     247          new dcFieldHidden ('id','')) 
     248; 
    89249# Get entry informations 
    90 if (!empty($_REQUEST['id'])) { 
    91      $page_title = __('Edit entry'); 
    92  
     250if (!empty($_REQUEST['id'])) 
     251{ 
    93252     $params['post_id'] = $_REQUEST['id']; 
    94  
     253      
    95254     $post = $core->blog->getPosts($params); 
    96  
    97      if ($post->isEmpty()) { 
     255      
     256     if ($post->isEmpty()) 
     257     { 
    98258          $core->error->add(__('This entry does not exist.')); 
    99259          $can_view_page = false; 
    100      } else { 
    101           $post_id = $post->post_id; 
    102           $cat_id = $post->cat_id; 
    103           $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 
    104           $post_format = $post->post_format; 
    105         # try to retrieve editor from post meta 
    106         $meta_editor = $core->meta->getMetaStr($post->post_meta,'editor'); 
    107         if (!empty($meta_editor)) { 
    108             $post_editor = $meta_editor; 
    109         } 
    110           $post_password = $post->post_password; 
    111           $post_url = $post->post_url; 
    112           $post_lang = $post->post_lang; 
    113           $post_title = $post->post_title; 
    114           $post_excerpt = $post->post_excerpt; 
    115           $post_excerpt_xhtml = $post->post_excerpt_xhtml; 
    116           $post_content = $post->post_content; 
    117           $post_content_xhtml = $post->post_content_xhtml; 
    118           $post_notes = $post->post_notes; 
    119           $post_status = $post->post_status; 
    120           $post_selected = (boolean) $post->post_selected; 
    121           $post_open_comment = (boolean) $post->post_open_comment; 
    122           $post_open_tb = (boolean) $post->post_open_tb; 
    123  
    124           $can_edit_post = $post->isEditable(); 
    125           $can_delete= $post->isDeletable(); 
    126  
     260     } 
     261     else 
     262     { 
     263          $form->id = $post_id = $post->post_id; 
     264          $form->cat_id = $post->cat_id; 
     265          $form->post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 
     266          $form->post_format = $post->post_format; 
     267          $form->post_password = $post->post_password; 
     268          $form->post_url = $post->post_url; 
     269          $form->post_lang = $post->post_lang; 
     270          $form->post_title = $post->post_title; 
     271          $form->post_excerpt = $post->post_excerpt; 
     272          $form->post_excerpt_xhtml = $post->post_excerpt_xhtml; 
     273          $form->post_content = $post->post_content; 
     274          $form->post_content_xhtml = $post->post_content_xhtml; 
     275          $form->post_notes = $post->post_notes; 
     276          $form->post_status = $post->post_status; 
     277          $form->post_selected = (boolean) $post->post_selected; 
     278          $form->post_open_comment = (boolean) $post->post_open_comment; 
     279          $form->post_open_tb = (boolean) $post->post_open_tb; 
     280          $form->can_edit_post = $post->isEditable(); 
     281          $form->can_delete= $post->isDeletable(); 
    127282          $next_rs = $core->blog->getNextPost($post,1); 
    128283          $prev_rs = $core->blog->getNextPost($post,-1); 
    129  
     284           
    130285          if ($next_rs !== null) { 
    131                $next_link = sprintf($post_link,$next_rs->post_id, 
    132                     html::escapeHTML($next_rs->post_title),__('Next entry').'&nbsp;&#187;'); 
    133                $next_headlink = sprintf($post_headlink,'next', 
    134                     html::escapeHTML($next_rs->post_title),$next_rs->post_id); 
    135           } 
    136  
     286               $_ctx->next_post = array('id' => $next_rs->post_id,'title' => $next_rs->post_title); 
     287          } 
    137288          if ($prev_rs !== null) { 
    138                $prev_link = sprintf($post_link,$prev_rs->post_id, 
    139                     html::escapeHTML($prev_rs->post_title),'&#171;&nbsp;'.__('Previous entry')); 
    140                $prev_headlink = sprintf($post_headlink,'previous', 
    141                     html::escapeHTML($prev_rs->post_title),$prev_rs->post_id); 
    142           } 
    143  
    144           try { 
    145                $core->media = new dcMedia($core); 
    146           } catch (Exception $e) { 
    147                $core->error->add($e->getMessage()); 
    148           } 
    149  
    150           # Sanitize trackbacks excerpt 
    151           $tb_excerpt = empty($_POST['tb_excerpt']) ? 
    152                $post_excerpt_xhtml.' '.$post_content_xhtml : 
    153                $_POST['tb_excerpt']; 
    154           $tb_excerpt = html::decodeEntities(html::clean($tb_excerpt)); 
    155           $tb_excerpt = text::cutString(html::escapeHTML($tb_excerpt), 255); 
    156           $tb_excerpt = preg_replace('/\s+/ms', ' ', $tb_excerpt); 
    157      } 
    158 } 
    159 if (isset($_REQUEST['section']) && $_REQUEST['section']=='trackbacks') { 
    160      $anchor = 'trackbacks'; 
    161 } else { 
    162      $anchor = 'comments'; 
    163 } 
    164  
    165 $comments_actions_page = new dcCommentsActionsPage($core,$core->adminurl->get('admin.post'),array('id' => $post_id, '_ANCHOR'=>$anchor,'section' => $anchor)); 
    166  
    167 if ($comments_actions_page->process()) { 
    168      return; 
    169 } 
    170  
    171 # Ping blogs 
    172 if (!empty($_POST['ping'])) 
    173 { 
    174      if (!empty($_POST['tb_urls']) && $post_id && $post_status == 1 && $can_edit_post) 
    175      { 
    176           $tb_urls = $_POST['tb_urls']; 
    177           $tb_urls = str_replace("\r", '', $tb_urls); 
    178           $tb_post_title = html::escapeHTML(trim(html::clean($post_title))); 
    179           $tb_post_url = $post->getURL(); 
    180  
    181           foreach (explode("\n", $tb_urls) as $tb_url) 
    182           { 
    183                try { 
    184                     $TB->ping($tb_url, $post_id, $tb_post_title, $tb_excerpt, $tb_post_url); 
    185                } catch (Exception $e) { 
    186                     $core->error->add($e->getMessage()); 
    187                } 
    188           } 
    189  
    190           if (!$core->error->flag()) { 
    191                dcPage::addSuccessNotice(__('All pings sent.')); 
    192                http::redirect($core->adminurl->get( 
    193                     'admin.post', 
    194                     array('id' => $post_id, 'tb'=> '1') 
    195                )); 
    196           } 
    197      } 
    198 } 
    199  
    200 # Format excerpt and content 
    201 elseif (!empty($_POST) && $can_edit_post) { 
    202  
    203      if (strpos($_POST['post_format'], ':')!==false) { 
    204           list($post_editor, $post_format) = explode(':', $_POST['post_format']); 
    205      } else { 
    206           $post_format = $_POST['post_format']; 
    207           $post_editor = ''; 
    208      } 
    209  
    210      $post_excerpt = $_POST['post_excerpt']; 
    211      $post_content = $_POST['post_content']; 
    212  
    213      $post_title = $_POST['post_title']; 
    214  
    215      $cat_id = (integer) $_POST['cat_id']; 
    216  
    217      if (isset($_POST['post_status'])) { 
    218           $post_status = (integer) $_POST['post_status']; 
    219      } 
    220  
    221      if (empty($_POST['post_dt'])) { 
    222           $post_dt = ''; 
    223      } else { 
    224           try 
    225           { 
    226                $post_dt = strtotime($_POST['post_dt']); 
    227                if ($post_dt == false || $post_dt == -1) { 
    228                     $bad_dt = true; 
    229                     throw new Exception(__('Invalid publication date')); 
    230                } 
    231                $post_dt = date('Y-m-d H:i',$post_dt); 
    232           } 
    233           catch (Exception $e) 
    234           { 
    235                $core->error->add($e->getMessage()); 
    236           } 
    237      } 
    238  
    239      $post_open_comment = !empty($_POST['post_open_comment']); 
    240      $post_open_tb = !empty($_POST['post_open_tb']); 
    241      $post_selected = !empty($_POST['post_selected']); 
    242      $post_lang = $_POST['post_lang']; 
    243      $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; 
    244  
    245      $post_notes = $_POST['post_notes']; 
    246  
    247      if (isset($_POST['post_url'])) { 
    248           $post_url = $_POST['post_url']; 
    249      } 
    250  
    251      $core->blog->setPostContent( 
    252           $post_id,$post_format,$post_lang, 
    253           $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml 
    254      ); 
    255 } 
    256  
    257 # Delete post 
    258 if (!empty($_POST['delete']) && $can_delete) 
    259 { 
    260      try { 
    261           # --BEHAVIOR-- adminBeforePostDelete 
    262           $core->callBehavior('adminBeforePostDelete',$post_id); 
    263           $core->blog->delPost($post_id); 
    264           http::redirect('posts.php'); 
    265      } catch (Exception $e) { 
    266           $core->error->add($e->getMessage()); 
    267      } 
    268 } 
    269  
    270 # Create or update post 
    271 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) 
    272 { 
    273      # Create category 
    274      if (!empty($_POST['new_cat_title']) && $core->auth->check('categories', $core->blog->id)) { 
    275  
    276           $cur_cat = $core->con->openCursor($core->prefix.'category'); 
    277           $cur_cat->cat_title = $_POST['new_cat_title']; 
    278           $cur_cat->cat_url = ''; 
    279  
    280           $parent_cat = !empty($_POST['new_cat_parent']) ? $_POST['new_cat_parent'] : ''; 
    281  
    282           # --BEHAVIOR-- adminBeforeCategoryCreate 
    283           $core->callBehavior('adminBeforeCategoryCreate', $cur_cat); 
    284  
    285           $cat_id = $core->blog->addCategory($cur_cat, (integer) $parent_cat); 
    286  
    287           # --BEHAVIOR-- adminAfterCategoryCreate 
    288           $core->callBehavior('adminAfterCategoryCreate', $cur_cat, $cat_id); 
    289      } 
    290  
    291      $cur = $core->con->openCursor($core->prefix.'post'); 
    292  
    293      $cur->post_title = $post_title; 
    294      $cur->cat_id = ($cat_id ? $cat_id : null); 
    295      $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; 
    296      $cur->post_format = $post_format; 
    297      $cur->post_meta = serialize(array('editor' => $post_editor)); 
    298      $cur->post_password = $post_password; 
    299      $cur->post_lang = $post_lang; 
    300      $cur->post_title = $post_title; 
    301      $cur->post_excerpt = $post_excerpt; 
    302      $cur->post_excerpt_xhtml = $post_excerpt_xhtml; 
    303      $cur->post_content = $post_content; 
    304      $cur->post_content_xhtml = $post_content_xhtml; 
    305      $cur->post_notes = $post_notes; 
    306      $cur->post_status = $post_status; 
    307      $cur->post_selected = (integer) $post_selected; 
    308      $cur->post_open_comment = (integer) $post_open_comment; 
    309      $cur->post_open_tb = (integer) $post_open_tb; 
    310  
    311      if (isset($_POST['post_url'])) { 
    312           $cur->post_url = $post_url; 
    313      } 
    314  
    315      # Update post 
    316      if ($post_id) { 
    317           try { 
    318             $meta = $core->meta; 
    319             $meta->delPostMeta($post_id,'editor'); 
    320             $meta->setPostMeta($post_id,'editor',$post_editor); 
    321  
    322                # --BEHAVIOR-- adminBeforePostUpdate 
    323                $core->callBehavior('adminBeforePostUpdate',$cur,$post_id); 
    324  
    325                $core->blog->updPost($post_id,$cur); 
    326  
    327                # --BEHAVIOR-- adminAfterPostUpdate 
    328                $core->callBehavior('adminAfterPostUpdate',$cur,$post_id); 
    329                dcPage::addSuccessNotice (sprintf(__('The post "%s" has been successfully updated'),html::escapeHTML($cur->post_title))); 
    330                http::redirect($core->adminurl->get( 
    331                     'admin.post', 
    332                     array('id' => $post_id) 
    333                )); 
    334           } catch (Exception $e) { 
    335                $core->error->add($e->getMessage()); 
    336           } 
    337      } else { 
    338           $cur->user_id = $core->auth->userID(); 
    339  
    340           try { 
    341                # --BEHAVIOR-- adminBeforePostCreate 
    342                $core->callBehavior('adminBeforePostCreate',$cur); 
    343  
    344                $return_id = $core->blog->addPost($cur); 
    345  
    346             $meta = $core->meta; 
    347             $meta->delPostMeta($return_id,'editor'); 
    348             $meta->setPostMeta($return_id,'editor',$post_editor); 
    349  
    350                # --BEHAVIOR-- adminAfterPostCreate 
    351                $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 
    352  
    353                dcPage::addSuccessNotice(__('Entry has been successfully created.')); 
    354                http::redirect($core->adminurl->get( 
    355                     'admin.post', 
    356                     array('id' => $return_id) 
    357                )); 
    358           } catch (Exception $e) { 
    359                $core->error->add($e->getMessage()); 
    360           } 
    361      } 
    362 } 
    363  
    364 # Getting categories 
    365 $categories_combo = dcAdminCombos::getCategoriesCombo( 
    366      $core->blog->getCategories(array('post_type'=>'post')) 
    367 ); 
     289               $_ctx->prev_post = array('id' => $prev_rs->post_id,'title' => $prev_rs->post_title); 
     290          } 
     291          $page_title = __('Edit entry'); 
     292 
     293     } 
     294} 
     295if ($post_id) { 
     296     $_ctx->post_id = $post->post_id; 
     297 
     298     $_ctx->preview_url = 
     299          $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 
     300          http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 
     301          '/'.$post->post_url); 
     302           
     303      
     304     $form_comment = new dcForm($core,'add-comment','comment.php'); 
     305     $form_comment 
     306          ->addField( 
     307               new dcFieldText('comment_author','', array( 
     308                    'maxlength'         => 255, 
     309                    'required'     => true, 
     310                    'label'        => __('Name:')))) 
     311          ->addField( 
     312               new dcFieldText('comment_email','', array( 
     313                    'maxlength'         => 255, 
     314                    'required'     => true, 
     315                    'label'        => __('Email:')))) 
     316          ->addField( 
     317               new dcFieldText('comment_site','', array( 
     318                    'maxlength'         => 255, 
     319                    'label'        => __('Web site:')))) 
     320          ->addField( 
     321               new dcFieldTextArea('comment_content','', array( 
     322                    'required'     => true, 
     323                    'label'        => __('Comment:')))) 
     324          ->addField( 
     325               new dcFieldHidden('post_id',$post_id)) 
     326          ->addField( 
     327               new dcFieldSubmit('add',__('Save'),array( 
     328                    'action' => 'addComment'))) 
     329          ; 
     330 
     331      
     332} 
     333 
     334$form->setup(); 
     335 
     336$sidebar_blocks = new ArrayObject(array( 
     337     'status-box' => array( 
     338          'title' => __('Status'), 
     339          'items' => array('post_status','post_dt','post_lang','post_format')), 
     340     'metas-box' => array( 
     341          'title' => __('Ordering'), 
     342          'items' => array('post_selected','cat_id')), 
     343     'options-box' => array( 
     344          'title' => __('Options'), 
     345          'items' => array('post_open_comment','post_open_tb','post_password','post_url')) 
     346)); 
     347 
     348$main_blocks = new ArrayObject(array( 
     349     "post_title","post_excerpt","post_content","post_notes" 
     350)); 
     351 
     352 
     353$_ctx->sidebar_blocks = $sidebar_blocks; 
     354$_ctx->main_blocks = $main_blocks; 
     355 
    368356/* DISPLAY 
    369357-------------------------------------------------------- */ 
     
    375363     $default_tab = 'comments'; 
    376364} 
    377 elseif (!empty($_GET['tb'])) { 
    378      $default_tab = 'trackbacks'; 
    379 } 
    380  
    381 if ($post_id) { 
    382      switch ($post_status) { 
    383           case 1: 
    384                $img_status = sprintf($img_status_pattern,__('Published'),'check-on.png'); 
    385                break; 
    386           case 0: 
    387                $img_status = sprintf($img_status_pattern,__('Unpublished'),'check-off.png'); 
    388                break; 
    389           case -1: 
    390                $img_status = sprintf($img_status_pattern,__('Scheduled'),'scheduled.png'); 
    391                break; 
    392           case -2: 
    393                $img_status = sprintf($img_status_pattern,__('Pending'),'check-wrn.png'); 
    394                break; 
    395           default: 
    396                $img_status = ''; 
    397      } 
    398      $edit_entry_str = __('&ldquo;%s&rdquo;'); 
    399      $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)).' '.$img_status; 
    400 } else { 
    401      $img_status = ''; 
    402 } 
    403  
    404 $admin_post_behavior = ''; 
    405 if (($core->auth->getOption('editor')==$post_editor)  
    406     && in_array($post_format, $core->getFormaters($core->auth->getOption('editor')))) { 
    407     $admin_post_behavior = $core->callBehavior('adminPostEditor'); 
    408 } 
    409  
    410 dcPage::open($page_title.' - '.__('Entries'), 
    411      dcPage::jsDatePicker(). 
    412      dcPage::jsModal(). 
    413      dcPage::jsMetaEditor(). 
    414     $admin_post_behavior. 
    415      dcPage::jsLoad('js/_post.js'). 
    416      dcPage::jsConfirmClose('entry-form','comment-form'). 
    417      # --BEHAVIOR-- adminPostHeaders 
    418      $core->callBehavior('adminPostHeaders'). 
    419      dcPage::jsPageTabs($default_tab). 
    420      $next_headlink."\n".$prev_headlink, 
    421      dcPage::breadcrumb( 
     365$page_title_edit = __('Edit entry'); 
     366$_ctx 
     367     ->setBreadCrumb( 
    422368          array( 
    423369               html::escapeHTML($core->blog->name) => '', 
    424370               __('Entries') => 'posts.php', 
    425371               ($post_id ? $page_title_edit : $page_title) => '' 
    426           )) 
    427 ); 
     372     )) 
     373     ->default_tab = $default_tab; 
     374$_ctx->post_status = $form->post_status; 
     375$_ctx->post_title = $form->post_title; 
     376if ($form->post_status == 1) { 
     377     $_ctx->post_url = $post->getURL(); 
     378} 
    428379 
    429380if (!empty($_GET['upd'])) { 
    430      dcPage::success(__('Entry has been successfully updated.')); 
     381     $_ctx->setAlert(__('Entry has been successfully updated.')); 
    431382} 
    432383elseif (!empty($_GET['crea'])) { 
    433      dcPage::success(__('Entry has been successfully created.')); 
     384     $_ctx->setAlert(__('Entry has been successfully created.')); 
    434385} 
    435386elseif (!empty($_GET['attached'])) { 
    436      dcPage::success(__('File has been successfully attached.')); 
     387     $_ctx->setAlert(__('File has been successfully attached.')); 
    437388} 
    438389elseif (!empty($_GET['rmattach'])) { 
    439      dcPage::success(__('Attachment has been successfully removed.')); 
    440 } 
    441  
     390     $_ctx->setAlert(__('Attachment has been successfully removed.')); 
     391} 
    442392if (!empty($_GET['creaco'])) { 
    443      dcPage::success(__('Comment has been successfully created.')); 
    444 } 
    445 if (!empty($_GET['tbsent'])) { 
    446      dcPage::success(__('All pings sent.')); 
    447 } 
    448  
    449 # XHTML conversion 
    450 if (!empty($_GET['xconv'])) 
    451 { 
    452      $post_excerpt = $post_excerpt_xhtml; 
    453      $post_content = $post_content_xhtml; 
    454      $post_format = 'xhtml'; 
    455  
    456      dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); 
    457 } 
    458  
    459 if ($post_id && $post->post_status == 1) { 
    460      echo '<p><a class="onblog_link outgoing" href="'.$post->getURL().'" title="'.$post_title.'">'.__('Go to this entry on the site').' <img src="images/outgoing-blue.png" alt="" /></a></p>'; 
    461 } 
    462 if ($post_id) 
    463 { 
    464      echo '<p class="nav_prevnext">'; 
    465      if ($prev_link) { echo $prev_link; } 
    466      if ($next_link && $prev_link) { echo ' | '; } 
    467      if ($next_link) { echo $next_link; } 
    468  
    469      # --BEHAVIOR-- adminPostNavLinks 
    470      $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null); 
    471  
    472      echo '</p>'; 
    473 } 
    474  
    475 # Exit if we cannot view page 
    476 if (!$can_view_page) { 
    477      dcPage::helpBlock('core_post'); 
    478      dcPage::close(); 
    479      exit; 
    480 } 
    481 /* Post form if we can edit post 
    482 -------------------------------------------------------- */ 
    483 if ($can_edit_post) { 
    484      if (count($formaters_combo)>0 && ($core->auth->getOption('editor') && $core->auth->getOption('editor')!='')) { 
    485           // temporay removed until we can switch easily editor 
    486         // $post_format_field = form::combo('post_format',$formaters_combo,"$post_editor:$post_format",'maximal'); 
    487  
    488         $post_format_field = sprintf('%s (%s)', $post_format, $post_editor); 
    489           $post_format_field .= form::hidden('post_format',"$post_editor:$post_format"); 
    490      } else { 
    491           $post_format_field = sprintf(__('Choose an active editor in %s.'),  
    492           '<a href="preferences.php#user-options">'.__('your preferences').'</a>' 
    493           ); 
    494           $post_format_field .= form::hidden('post_format','xhtml'); 
    495      } 
    496  
    497      $sidebar_items = new ArrayObject(array( 
    498           'status-box' => array( 
    499                'title' => __('Status'), 
    500                'items' => array( 
    501                     'post_status' => 
    502                          '<p class="entry-status"><label for="post_status">'.__('Entry status').' '.$img_status.'</label>'. 
    503                          form::combo('post_status',$status_combo,$post_status,'maximal','',!$can_publish). 
    504                          '</p>', 
    505                     'post_dt' => 
    506                          '<p><label for="post_dt">'.__('Publication date and hour').'</label>'. 
    507                          form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). 
    508                          '</p>', 
    509                     'post_lang' => 
    510                          '<p><label for="post_lang">'.__('Entry language').'</label>'. 
    511                          form::combo('post_lang',$lang_combo,$post_lang). 
    512                          '</p>', 
    513                     'post_format' => 
    514                          '<div>'. 
    515                          '<h5 id="label_format"><label for="post_format" class="classic">'.__('Text formatting').'</label></h5>'. 
    516                          '<p>'.$post_format_field.'</p>'. 
    517                          '<p class="format_control control_no_xhtml">'. 
    518                          '<a id="convert-xhtml" class="button'.($post_id && $post_format != 'wiki' ? ' hide' : '').'" href="'. 
    519                          $core->adminurl->get('admin.post',array('id'=> $post_id,'xconv'=> '1')). 
    520                          '">'. 
    521                          __('Convert to XHTML').'</a></p></div>')), 
    522           'metas-box' => array( 
    523                'title' => __('Filing'), 
    524                'items' => array( 
    525                     'post_selected' => 
    526                          '<p><label for="post_selected" class="classic">'. 
    527                          form::checkbox('post_selected',1,$post_selected).' '. 
    528                          __('Selected entry').'</label></p>', 
    529                     'cat_id' => 
    530                          '<div>'. 
    531                          '<h5 id="label_cat_id">'.__('Category').'</h5>'. 
    532                          '<p><label for="cat_id">'.__('Category:').'</label>'. 
    533                          form::combo('cat_id',$categories_combo,$cat_id,'maximal'). 
    534                          '</p>'. 
    535                          ($core->auth->check('categories', $core->blog->id) ? 
    536                               '<div>'. 
    537                               '<h5 id="create_cat">'.__('Add a new category').'</h5>'. 
    538                               '<p><label for="new_cat_title">'.__('Title:').' '. 
    539                               form::field('new_cat_title',30,255,'','maximal').'</label></p>'. 
    540                               '<p><label for="new_cat_parent">'.__('Parent:').' '. 
    541                               form::combo('new_cat_parent',$categories_combo,'','maximal'). 
    542                               '</label></p>'. 
    543                               '</div>' 
    544                          : ''). 
    545                          '</div>')), 
    546           'options-box' => array( 
    547                'title' => __('Options'), 
    548                'items' => array( 
    549                     'post_open_comment_tb' => 
    550                          '<div>'. 
    551                          '<h5 id="label_comment_tb">'.__('Comments and trackbacks list').'</h5>'. 
    552                          '<p><label for="post_open_comment" class="classic">'. 
    553                          form::checkbox('post_open_comment',1,$post_open_comment).' '. 
    554                          __('Accept comments').'</label></p>'. 
    555                          ($core->blog->settings->system->allow_comments ? 
    556                               (isContributionAllowed($post_id,strtotime($post_dt),true) ? 
    557                                    '' : 
    558                                    '<p class="form-note warn">'. 
    559                                    __('Warning: Comments are not more accepted for this entry.').'</p>') : 
    560                               '<p class="form-note warn">'. 
    561                               __('Comments are not accepted on this blog so far.').'</p>'). 
    562                          '<p><label for="post_open_tb" class="classic">'. 
    563                          form::checkbox('post_open_tb',1,$post_open_tb).' '. 
    564                          __('Accept trackbacks').'</label></p>'. 
    565                          ($core->blog->settings->system->allow_trackbacks ? 
    566                               (isContributionAllowed($post_id,strtotime($post_dt),false) ? 
    567                                    '' : 
    568                                    '<p class="form-note warn">'. 
    569                                    __('Warning: Trackbacks are not more accepted for this entry.').'</p>') : 
    570                               '<p class="form-note warn">'.__('Trackbacks are not accepted on this blog so far.').'</p>'). 
    571                          '</div>', 
    572                     'post_password' => 
    573                          '<p><label for="post_password">'.__('Password').'</label>'. 
    574                          form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). 
    575                          '</p>', 
    576                     'post_url' => 
    577                          '<div class="lockable">'. 
    578                          '<p><label for="post_url">'.__('Edit basename').'</label>'. 
    579                          form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). 
    580                          '</p>'. 
    581                          '<p class="form-note warn">'. 
    582                          __('Warning: If you set the URL manually, it may conflict with another entry.'). 
    583                          '</p></div>' 
    584      )))); 
    585  
    586      $main_items = new ArrayObject(array( 
    587           "post_title" => 
    588                '<p class="col">'. 
    589                '<label class="required no-margin bold"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 
    590                form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). 
    591                '</p>', 
    592  
    593           "post_excerpt" => 
    594                '<p class="area" id="excerpt-area"><label for="post_excerpt" class="bold">'.__('Excerpt:').' <span class="form-note">'. 
    595                __('Introduction to the post.').'</span></label> '. 
    596                form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). 
    597                '</p>', 
    598  
    599           "post_content" => 
    600                '<p class="area" id="content-area"><label class="required bold" '. 
    601                'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 
    602                form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). 
    603                '</p>', 
    604  
    605           "post_notes" => 
    606                '<p class="area" id="notes-area"><label for="post_notes" class="bold">'.__('Personal notes:').' <span class="form-note">'. 
    607                __('Unpublished notes.').'</span></label>'. 
    608                form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). 
    609                '</p>' 
    610           ) 
    611      ); 
    612  
    613      # --BEHAVIOR-- adminPostFormItems 
    614      $core->callBehavior('adminPostFormItems',$main_items,$sidebar_items, isset($post) ? $post : null); 
    615  
    616      echo '<div class="multi-part" title="'.($post_id ? __('Edit entry') : __('New entry')).'" id="edit-entry">'; 
    617      echo '<form action="'.$core->adminurl->get('admin.post').'" method="post" id="entry-form">'; 
    618      echo '<div id="entry-wrapper">'; 
    619      echo '<div id="entry-content"><div class="constrained">'; 
    620  
    621      echo '<h3 class="out-of-screen-if-js">'.__('Edit post').'</h3>'; 
    622  
    623      foreach ($main_items as $id => $item) { 
    624           echo $item; 
    625      } 
    626  
    627      # --BEHAVIOR-- adminPostForm (may be deprecated) 
    628      $core->callBehavior('adminPostForm',isset($post) ? $post : null); 
    629  
    630      echo 
    631      '<p class="border-top">'. 
    632      ($post_id ? form::hidden('id',$post_id) : ''). 
    633      '<input type="submit" value="'.__('Save').' (s)" '. 
    634      'accesskey="s" name="save" /> '; 
    635      if ($post_id) { 
    636           $preview_url = 
    637           $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 
    638           http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 
    639           '/'.$post->post_url); 
    640           echo '<a id="post-preview" href="'.$preview_url.'" class="button modal" accesskey="p">'.__('Preview').' (p)'.'</a> '; 
    641      } else { 
    642           echo 
    643           '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; 
    644      } 
    645  
    646      echo 
    647      ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). 
    648      $core->formNonce(). 
    649      '</p>'; 
    650  
    651      echo '</div></div>';          // End #entry-content 
    652      echo '</div>';      // End #entry-wrapper 
    653  
    654      echo '<div id="entry-sidebar">'; 
    655  
    656      foreach ($sidebar_items as $id => $c) { 
    657           echo '<div id="'.$id.'" class="sb-box">'. 
    658                '<h4>'.$c['title'].'</h4>'; 
    659           foreach ($c['items'] as $e_name=>$e_content) { 
    660                echo $e_content; 
    661           } 
    662           echo '</div>'; 
    663      } 
    664  
    665  
    666      # --BEHAVIOR-- adminPostFormSidebar (may be deprecated) 
    667      $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null); 
    668      echo '</div>';      // End #entry-sidebar 
    669  
    670      echo '</form>'; 
    671  
    672      # --BEHAVIOR-- adminPostForm 
    673      $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null); 
    674  
    675      echo '</div>'; 
    676 } 
    677  
    678 if ($post_id) 
    679 { 
    680      /* Comments 
    681      -------------------------------------------------------- */ 
    682  
    683      $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 
    684  
    685      $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); 
    686  
    687      echo 
    688      '<div id="comments" class="clear multi-part" title="'.__('Comments').'">'; 
    689      $combo_action = $comments_actions_page->getCombo(); 
    690      $has_action = !empty($combo_action) && !$comments->isEmpty(); 
    691      echo 
    692      '<p class="top-add"><a class="button add" href="#comment-form">'.__('Add a comment').'</a></p>'; 
    693  
    694      if ($has_action) { 
    695           echo '<form action="'.$core->adminurl->get('admin.post').'" id="form-comments" method="post">'; 
    696      } 
    697  
    698      echo '<h3>'.__('Comments').'</h3>'; 
    699      if (!$comments->isEmpty()) { 
    700           showComments($comments,$has_action); 
    701      } else { 
    702           echo '<p>'.__('No comments').'</p>'; 
    703      } 
    704  
    705      if ($has_action) { 
    706           echo 
    707           '<div class="two-cols">'. 
    708           '<p class="col checkboxes-helpers"></p>'. 
    709  
    710           '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. 
    711           form::combo('action',$combo_action). 
    712           form::hidden(array('section'),'comments'). 
    713           form::hidden(array('id'),$post_id). 
    714           $core->formNonce(). 
    715           '<input type="submit" value="'.__('ok').'" /></p>'. 
    716           '</div>'. 
    717           '</form>'; 
    718      } 
    719      /* Add a comment 
    720      -------------------------------------------------------- */ 
    721  
    722      echo 
    723      '<div class="fieldset clear">'. 
    724      '<h3>'.__('Add a comment').'</h3>'. 
    725  
    726      '<form action="comment.php" method="post" id="comment-form">'. 
    727      '<div class="constrained">'. 
    728      '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').'</label>'. 
    729      form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). 
    730      '</p>'. 
    731  
    732      '<p><label for="comment_email">'.__('Email:').'</label>'. 
    733      form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). 
    734      '</p>'. 
    735  
    736      '<p><label for="comment_site">'.__('Web site:').'</label>'. 
    737      form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). 
    738      '</p>'. 
    739  
    740      '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. 
    741      __('Comment:').'</label> '. 
    742      form::textarea('comment_content',50,8,html::escapeHTML('')). 
    743      '</p>'. 
    744  
    745      '<p>'. 
    746      form::hidden('post_id',$post_id). 
    747      $core->formNonce(). 
    748      '<input type="submit" name="add" value="'.__('Save').'" /></p>'. 
    749      '</div>'. #constrained 
    750  
    751      '</form>'. 
    752      '</div>'. #add comment 
    753      '</div>'; #comments 
    754 } 
    755  
    756 if ($post_id && $post_status == 1) 
    757 { 
    758      /* Trackbacks 
    759      -------------------------------------------------------- */ 
    760  
    761      $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 
    762      $trackbacks = $core->blog->getComments(array_merge($params, array('comment_trackback' => 1))); 
    763  
    764      # Actions combo box 
    765      $combo_action = $comments_actions_page->getCombo(); 
    766      $has_action = !empty($combo_action) && !$trackbacks->isEmpty(); 
    767  
    768      if (!empty($_GET['tb_auto'])) { 
    769           $tb_urls = implode("\n", $TB->discover($post_excerpt_xhtml.' '.$post_content_xhtml)); 
    770      } 
    771  
    772      # Display tab 
    773      echo 
    774      '<div id="trackbacks" class="clear multi-part" title="'.__('Trackbacks').'">'; 
    775  
    776      # tracbacks actions 
    777      if ($has_action) { 
    778           echo '<form action="post.php" id="form-trackbacks" method="post">'; 
    779      } 
    780  
    781      echo '<h3>'.__('Trackbacks received').'</h3>'; 
    782  
    783      if (!$trackbacks->isEmpty()) { 
    784           showComments($trackbacks, $has_action, true); 
    785      } else { 
    786           echo '<p>'.__('No trackback').'</p>'; 
    787      } 
    788  
    789      if ($has_action) { 
    790           echo 
    791           '<div class="two-cols">'. 
    792           '<p class="col checkboxes-helpers"></p>'. 
    793  
    794           '<p class="col right"><label for="action" class="classic">'.__('Selected trackbacks action:').'</label> '. 
    795           form::combo('action', $combo_action). 
    796           form::hidden('id',$post_id). 
    797           form::hidden(array('section'),'trackbacks'). 
    798           $core->formNonce(). 
    799           '<input type="submit" value="'.__('ok').'" /></p>'. 
    800           '</div>'. 
    801           '</form>'; 
    802      } 
    803  
    804      /* Add trackbacks 
    805      -------------------------------------------------------- */ 
    806      if ($can_edit_post && $post->post_status) { 
    807           echo 
    808           '<div class="fieldset clear">'; 
    809  
    810           echo 
    811           '<h3>'.__('Ping blogs').'</h3>'. 
    812           '<form action="post.php?id='.$post_id.'" id="trackback-form" method="post">'. 
    813           '<p><label for="tb_urls" class="area">'.__('URLs to ping:').'</label>'. 
    814           form::textarea('tb_urls', 60, 5, $tb_urls). 
    815           '</p>'. 
    816  
    817           '<p><label for="tb_excerpt" class="area">'.__('Excerpt to send:').'</label>'. 
    818           form::textarea('tb_excerpt', 60, 5, $tb_excerpt).'</p>'. 
    819  
    820           '<p>'. 
    821           $core->formNonce(). 
    822           '<input type="submit" name="ping" value="'.__('Ping blogs').'" />'. 
    823           (empty($_GET['tb_auto']) ? 
    824                '&nbsp;&nbsp;<a class="button" href="'. 
    825                'post.php?id='.$post_id.'&amp;tb_auto=1&amp;tb=1'. 
    826                '">'.__('Auto discover ping URLs').'</a>' 
    827           : ''). 
    828           '</p>'. 
    829           '</form>'; 
    830  
    831           $pings = $TB->getPostPings($post_id); 
    832  
    833           if (!$pings->isEmpty()) 
    834           { 
    835                echo '<h3>'.__('Previously sent pings').'</h3>'; 
    836  
    837                echo '<ul class="nice">'; 
    838                while ($pings->fetch()) { 
    839                     echo 
    840                     '<li>'.dt::dt2str(__('%Y-%m-%d %H:%M'), $pings->ping_dt).' - '. 
    841                     $pings->ping_url.'</li>'; 
    842                } 
    843                echo '</ul>'; 
    844           } 
    845  
    846           echo '</div>'; 
    847      } 
    848  
    849      echo '</div>'; #trackbacks 
    850 } 
    851  
    852 # Controls comments or trakbacks capabilities 
    853 function isContributionAllowed($id,$dt,$com=true) 
    854 { 
    855      global $core; 
    856  
    857      if (!$id) { 
    858           return true; 
    859      } 
    860      if ($com) { 
    861           if (($core->blog->settings->system->comments_ttl == 0) || 
    862                (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { 
    863                return true; 
    864           } 
    865      } else { 
    866           if (($core->blog->settings->system->trackbacks_ttl == 0) || 
    867                (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { 
    868                return true; 
    869           } 
    870      } 
    871      return false; 
    872 } 
    873  
    874 # Show comments or trackbacks 
    875 function showComments($rs,$has_action,$tb=false) 
    876 { 
    877      echo 
    878      '<div class="table-outer">'. 
    879      '<table class="comments-list"><tr>'. 
    880      '<th colspan="2" class="first">'.__('Author').'</th>'. 
    881      '<th>'.__('Date').'</th>'. 
    882      '<th class="nowrap">'.__('IP address').'</th>'. 
    883      '<th>'.__('Status').'</th>'. 
    884      '<th>'.__('Edit').'</th>'. 
    885      '</tr>'; 
    886      $comments = array(); 
    887      if (isset($_REQUEST['comments'])) { 
    888           foreach ($_REQUEST['comments'] as $v) { 
    889                $comments[(integer)$v]=true; 
    890           } 
    891      } 
    892  
    893      while($rs->fetch()) 
    894      { 
    895           $comment_url = 'comment.php?id='.$rs->comment_id; 
    896  
    897           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    898           switch ($rs->comment_status) { 
    899                case 1: 
    900                     $img_status = sprintf($img,__('Published'),'check-on.png'); 
    901                     break; 
    902                case 0: 
    903                     $img_status = sprintf($img,__('Unpublished'),'check-off.png'); 
    904                     break; 
    905                case -1: 
    906                     $img_status = sprintf($img,__('Pending'),'check-wrn.png'); 
    907                     break; 
    908                case -2: 
    909                     $img_status = sprintf($img,__('Junk'),'junk.png'); 
    910                     break; 
    911           } 
    912  
    913           echo 
    914           '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. 
    915           ' id="c'.$rs->comment_id.'">'. 
    916  
    917           '<td class="nowrap">'. 
    918           ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,isset($comments[$rs->comment_id]),'','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'. 
    919           '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'. 
    920           '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. 
    921           '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. 
    922           '<td class="nowrap status">'.$img_status.'</td>'. 
    923           '<td class="nowrap status"><a href="'.$comment_url.'">'. 
    924           '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /> '.__('Edit').'</a></td>'. 
    925  
    926           '</tr>'; 
    927      } 
    928  
    929      echo '</table></div>'; 
    930 } 
    931  
    932 dcPage::helpBlock('core_post','core_trackbacks','core_wiki'); 
    933 dcPage::close(); 
     393     $_ctx->setAlert(__('Comment has been successfully created.')); 
     394}     
     395      
     396$core->tpl->display('post.html.twig'); 
     397?> 
  • inc/admin/prepend.php

    r2613 r2715  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    174174*/ 
    175175} 
     176 
     177$core->adminurl = new dcAdminURL($core); 
     178 
     179$core->adminurl->register('admin.posts','posts.php'); 
     180$core->adminurl->register('admin.post','post.php'); 
     181$core->adminurl->register('admin.blog.theme','blog_theme.php'); 
     182$core->adminurl->register('admin.blog.pref','blog_pref.php'); 
     183$core->adminurl->register('admin.blogs','blogs.php'); 
     184$core->adminurl->register('admin.categories','categories.php'); 
     185$core->adminurl->register('admin.category','category.php'); 
     186$core->adminurl->register('admin.comments','comments.php'); 
     187$core->adminurl->register('admin.comments','comment.php'); 
     188$core->adminurl->register('admin.help','help.php'); 
     189$core->adminurl->register('admin.home','index.php'); 
     190$core->adminurl->register('admin.langs','langs.php'); 
     191$core->adminurl->register('admin.media','media.php'); 
     192$core->adminurl->register('admin.media_item','media_item.php'); 
     193$core->adminurl->register('admin.plugins','plugins.php'); 
     194$core->adminurl->register('admin.plugin','plugin.php'); 
     195$core->adminurl->register('admin.user.preferences','preferences.php'); 
     196$core->adminurl->register('admin.user','user.php'); 
     197$core->adminurl->register('admin.users','users.php'); 
    176198 
    177199if ($core->auth->userID() && $core->blog !== null) 
  • inc/admin/prepend.php

    r2708 r2715  
    2424function dc_load_locales() { 
    2525     global $_lang, $core; 
    26  
     26      
    2727     $_lang = $core->auth->getInfo('user_lang'); 
    2828     $_lang = preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$_lang) ? $_lang : 'en'; 
    29  
     29      
    3030     l10n::lang($_lang); 
    3131     if (l10n::set(dirname(__FILE__).'/../../locales/'.$_lang.'/date') === false && $_lang != 'en') { 
     
    4040{ 
    4141     global $core; 
    42  
     42      
    4343     $core->auth->user_prefs->addWorkspace('interface'); 
    4444     $user_ui_iconset = @$core->auth->user_prefs->interface->iconset; 
    4545     if (($user_ui_iconset) && ($img)) { 
    4646          $icon = false; 
    47           if ((preg_match('/^images\/menu\/(.+)$/',$img,$m)) || 
     47          if ((preg_match('/^images\/menu\/(.+)$/',$img,$m)) ||  
    4848               (preg_match('/^index\.php\?pf=(.+)$/',$img,$m))) { 
    4949               if ($m[1]) { 
     
    6565     # We have session information in constants 
    6666     $_COOKIE[DC_SESSION_NAME] = DC_AUTH_SESS_ID; 
    67  
     67      
    6868     if (!$core->auth->checkSession(DC_AUTH_SESS_UID)) { 
    6969          throw new Exception('Invalid session data.'); 
    7070     } 
    71  
     71      
    7272     # Check nonce from POST requests 
    7373     if (!empty($_POST)) 
     
    7777          } 
    7878     } 
    79  
     79      
    8080     if (empty($_SESSION['sess_blog_id'])) { 
    8181          throw new Exception('Permission denied.'); 
    8282     } 
    83  
     83      
    8484     # Loading locales 
    8585     dc_load_locales(); 
    86  
     86      
    8787     $core->setBlog($_SESSION['sess_blog_id']); 
    8888     if (!$core->blog->id) { 
     
    100100               $p[3] = '/'; 
    101101               call_user_func_array('setcookie',$p); 
    102  
     102                
    103103               http::redirect('auth.php'); 
    104104          } 
     
    108108               ,20); 
    109109     } 
    110  
     110      
    111111     # Check nonce from POST requests 
    112112     if (!empty($_POST)) 
     
    119119          } 
    120120     } 
    121  
    122  
     121      
     122      
    123123     if (!empty($_REQUEST['switchblog']) 
    124124     && $core->auth->getPermissions($_REQUEST['switchblog']) !== false) 
     
    131131               unset($_SESSION['media_manager_page']); 
    132132          } 
    133  
     133           
    134134          # Removing switchblog from URL 
    135135          $redir = $_SERVER['REQUEST_URI']; 
     
    139139          exit; 
    140140     } 
    141  
     141      
    142142     # Check blog to use and log out if no result 
    143143     if (isset($_SESSION['sess_blog_id'])) 
     
    154154          } 
    155155     } 
    156  
     156      
    157157     # Loading locales 
    158158     dc_load_locales(); 
    159  
     159      
    160160     if (isset($_SESSION['sess_blog_id'])) { 
    161161          $core->setBlog($_SESSION['sess_blog_id']); 
     
    165165     } 
    166166 
    167 /* 
     167/*    
    168168     # Check add to my fav fired 
    169169     if (!empty($_REQUEST['add-favorite'])) { 
     
    206206     } 
    207207     unset($f); 
    208  
     208      
    209209     if (($hfiles = @scandir($locales_root.$_lang.'/help')) !== false) 
    210210     { 
     
    227227     # [] : Title, URL, small icon, large icon, permissions, id, class 
    228228     # NB : '*' in permissions means any, null means super admin only 
    229  
    230  
     229      
     230      
    231231     # Menus creation 
    232232     $_menu = new ArrayObject(); 
     
    246246     } 
    247247 
    248  
     248      
    249249     # Set menu titles 
    250  
     250      
    251251     $_menu['System']->title = __('System settings'); 
    252252     $_menu['Blog']->title = __('Blog'); 
     
    278278          preg_match('/post.php$/',$_SERVER['REQUEST_URI']), 
    279279          $core->auth->check('usage,contentadmin',$core->blog->id)); 
    280  
     280      
    281281     $_menu['System']->prependItem(__('Update'),'update.php','images/menu/update.png', 
    282282          preg_match('/update.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 
     
    301301} 
    302302 
     303# Add admin default templates path 
     304$core->tpl->getLoader()->addPath(dirname(__FILE__).'/default-templates'); 
     305# Set admin context 
     306$_ctx = new dcAdminContext($core); 
     307$core->tpl->addExtension($_ctx); 
     308 
     309# --BEHAVIOR-- adminPrepend 
     310$core->callBehavior('adminPrepend',$core,$_ctx); 
     311?> 
  • inc/core/class.dc.core.php

    r2683 r2715  
    901901               'edit_size' => 24, 
    902902               'enable_wysiwyg' => true, 
     903            'editor' => 'dcLegacyEditor', 
    903904               'post_format' => 'wiki' 
    904905          ); 
  • inc/core/class.dc.core.php

    r2706 r2715  
    3939     public $rest;       ///< <b>dcRestServer</b> dcRestServer object 
    4040     public $log;        ///< <b>dcLog</b>             dcLog object 
     41     public $tpl;        ///< <b>Twig_Environment</b>  Twig_Environment object 
    4142     public $stime;      ///< <b>float</b>             starting time 
    42  
     43      
    4344     private $versions = null; 
    4445     private $formaters = array(); 
    4546     private $behaviors = array(); 
    4647     private $post_types = array(); 
    47  
     48      
    4849     /** 
    4950     dcCore constructor inits everything related to Dotclear. It takes arguments 
    5051     to init database connection. 
    51  
     52      
    5253     @param    driver    <b>string</b>  Database driver name 
    5354     @param    host      <b>string</b>  Database hostname 
     
    6768 
    6869          $this->con = dbLayer::init($driver,$host,$db,$user,$password,$persist); 
    69  
     70           
    7071          # define weak_locks for mysql 
    7172          if ($this->con instanceof mysqlConnection) { 
     
    7475               mysqliConnection::$weak_locks = true; 
    7576          } 
    76  
     77           
    7778          # define searchpath for postgresql 
    7879          if ($this->con instanceof pgsqlConnection) 
     
    8687               } 
    8788          } 
    88  
     89           
    8990          $this->prefix = $prefix; 
    90  
     91           
    9192          $this->error = new dcError(); 
    9293          $this->auth = $this->authInstance(); 
    9394          $this->session = new sessionDB($this->con,$this->prefix.'session',DC_SESSION_NAME,'',null,DC_ADMIN_SSL); 
    9495          $this->url = new dcUrlHandlers(); 
    95  
     96           
    9697          $this->plugins = new dcPlugins($this); 
    97  
     98           
    9899          $this->rest = new dcRestServer($this); 
    99  
     100           
    100101          $this->meta = new dcMeta($this); 
    101  
     102           
    102103          $this->log = new dcLog($this); 
    103104     } 
    104  
     105      
    105106     private function authInstance() 
    106107     { 
     
    112113               $c = DC_AUTH_CLASS; 
    113114          } 
    114  
     115           
    115116          if (!class_exists($c)) { 
    116117               throw new Exception('Authentication class '.$c.' does not exist.'); 
    117118          } 
    118  
     119           
    119120          if ($c != 'dcAuth' && !is_subclass_of($c,'dcAuth')) { 
    120121               throw new Exception('Authentication class '.$c.' does not inherit dcAuth.'); 
    121122          } 
    122  
     123           
    123124          return new $c($this); 
    124125     } 
    125  
    126  
     126      
     127     /** 
     128     Create template environment (Twig_Environment instance) 
     129      
     130     default-templates path must be added from admin|public/prepend.php with: 
     131     $core->tpl->getLoader()->addPath('PATH_TO/default-templates'); 
     132     Selected theme path must be added with: 
     133     $core->tpl->getLoader()->prependPath('PATH_TO/MY_THEME'); 
     134     */ 
     135     public function loadTemplateEnvironment() 
     136     { 
     137          $cache_dir = path::real(DC_TPL_CACHE.'/twtpl',false); 
     138          if (!is_dir($cache_dir)) { 
     139               try { 
     140                    files::makeDir($cache_dir); 
     141               } catch (Exception $e) { 
     142                    $cache_dir = false; 
     143               } 
     144          } 
     145           
     146          $this->tpl = new Twig_Environment( 
     147               new Twig_Loader_Filesystem(dirname(__FILE__).'/../swf'), 
     148               array( 
     149                    'auto_reload' => true, 
     150                    'autoescape' => false, 
     151                    'base_template_class' => 'Twig_Template', 
     152                    'cache' => $cache_dir,  
     153                    'charset' => 'UTF-8', 
     154                    'debug' => DC_DEBUG, 
     155                    'optimizations' => -1, 
     156                    'strict_variables' => 0 //DC_DEBUG // Please fix undefined variables! 
     157               ) 
     158          ); 
     159          $this->tpl->addExtension(new dcFormExtension($this)); 
     160          $this->tpl->addExtension(new dcTabExtension($this)); 
     161     } 
     162      
    127163     /// @name Blog init methods 
    128164     //@{ 
    129165     /** 
    130166     Sets a blog to use in <var>blog</var> property. 
    131  
     167      
    132168     @param    id        <b>string</b>       Blog ID 
    133169     */ 
     
    136172          $this->blog = new dcBlog($this, $id); 
    137173     } 
    138  
     174      
    139175     /** 
    140176     Unsets <var>blog</var> property. 
     
    145181     } 
    146182     //@} 
    147  
    148  
     183      
     184      
    149185     /// @name Blog status methods 
    150186     //@{ 
    151187     /** 
    152188     Returns an array of available blog status codes and names. 
    153  
     189      
    154190     @return   <b>array</b> Simple array with codes in keys and names in value 
    155191     */ 
     
    162198          ); 
    163199     } 
    164  
     200      
    165201     /** 
    166202     Returns a blog status name given to a code. This is intended to be 
    167203     human-readable and will be translated, so never use it for tests. 
    168204     If status code does not exist, returns <i>offline</i>. 
    169  
     205      
    170206     @param    s    <b>integer</b> Status code 
    171207     @return   <b>string</b> Blog status name 
     
    180216     } 
    181217     //@} 
    182  
     218      
    183219     /// @name Admin nonce secret methods 
    184220     //@{ 
    185  
     221      
    186222     public function getNonce() 
    187223     { 
    188224          return crypt::hmac(DC_MASTER_KEY,session_id()); 
    189225     } 
    190  
     226      
    191227     public function checkNonce($secret) 
    192228     { 
     
    194230               return false; 
    195231          } 
    196  
     232           
    197233          return $secret == crypt::hmac(DC_MASTER_KEY,session_id()); 
    198234     } 
    199  
     235      
    200236     public function formNonce() 
    201237     { 
     
    203239               return; 
    204240          } 
    205  
     241           
    206242          return form::hidden(array('xd_check'),$this->getNonce()); 
    207243     } 
    208244     //@} 
    209  
     245      
    210246     /// @name Text Formatters methods 
    211247     //@{ 
     
    225261          } 
    226262     } 
    227  
     263      
    228264     /// @name Text Formatters methods 
    229265     //@{ 
     
    232268     transform text. The function must be a valid callback and takes one 
    233269     argument: the string to transform. It returns the transformed string. 
    234  
     270      
    235271     @param    name      <b>string</b>       Formater name 
    236272     @param    func      <b>callback</b>     Function to use, must be a valid and callable callback 
     
    256292          return $editors; 
    257293     } 
    258  
     294      
    259295     /** 
    260296     Returns formaters list by editor 
    261  
     297      
    262298     @param    editor_id <b>string</b>  Editor id (dcLegacyEditor, dcCKEditor, ...) 
    263299     @return   <b>array</b> An array of formaters names in values. 
     
    288324          return $formaters_list; 
    289325     } 
    290  
     326      
    291327     /** 
    292328     If <var>$name</var> is a valid formater, it returns <var>$str</var> 
    293329     transformed using that formater. 
    294  
     330      
    295331     @param    editor_id <b>string</b>  Editor id (dcLegacyEditor, dcCKEditor, ...) 
    296332     @param    name      <b>string</b>       Formater name 
     
    303339               return call_user_func($this->formaters[$editor_id][$name],$str); 
    304340          } 
    305  
     341           
    306342          return $str; 
    307343     } 
    308344     //@} 
    309  
     345      
    310346     /** 
    311347     If <var>$name</var> is a valid formater, it returns <var>$str</var> 
     
    322358     //@} 
    323359 
    324  
     360      
    325361     /// @name Behaviors methods 
    326362     //@{ 
     
    328364     Adds a new behavior to behaviors stack. <var>$func</var> must be a valid 
    329365     and callable callback. 
    330  
     366      
    331367     @param    behavior  <b>string</b>       Behavior name 
    332368     @param    func      <b>callback</b>     Function to call 
     
    338374          } 
    339375     } 
    340  
     376      
    341377     /** 
    342378     Tests if a particular behavior exists in behaviors stack. 
    343  
     379      
    344380     @param    behavior  <b>string</b>  Behavior name 
    345381     @return   <b>boolean</b> 
     
    349385          return isset($this->behaviors[$behavior]); 
    350386     } 
    351  
     387      
    352388     /** 
    353389     Get behaviors stack (or part of). 
    354  
     390      
    355391     @param    behavior  <b>string</b>       Behavior name 
    356392     @return   <b>array</b> 
     
    359395     { 
    360396          if (empty($this->behaviors)) return null; 
    361  
     397           
    362398          if ($behavior == '') { 
    363399               return $this->behaviors; 
     
    365401               return $this->behaviors[$behavior]; 
    366402          } 
    367  
     403           
    368404          return array(); 
    369405     } 
    370  
     406      
    371407     /** 
    372408     Calls every function in behaviors stack for a given behavior and returns 
    373409     concatened result of each function. 
    374  
     410      
    375411     Every parameters added after <var>$behavior</var> will be pass to 
    376412     behavior calls. 
    377  
     413      
    378414     @param    behavior  <b>string</b>  Behavior name 
    379415     @return   <b>string</b> Behavior concatened result 
     
    385421               $args = func_get_args(); 
    386422               array_shift($args); 
    387  
     423                
    388424               $res = ''; 
    389  
     425                
    390426               foreach ($this->behaviors[$behavior] as $f) { 
    391427                    $res .= call_user_func_array($f,$args); 
    392428               } 
    393  
     429                
    394430               return $res; 
    395431          } 
    396432     } 
    397433     //@} 
    398  
     434      
    399435     /// @name Post types URLs management 
    400436     //@{ 
     
    404440               $type = 'post'; 
    405441          } 
    406  
     442           
    407443          $url = sprintf($this->post_types[$type]['admin_url'],$post_id); 
    408444          return $escaped ? html::escapeURL($url) : $url; 
    409445     } 
    410  
     446      
    411447     public function getPostPublicURL($type,$post_url,$escaped=true) 
    412448     { 
     
    414450               $type = 'post'; 
    415451          } 
    416  
     452           
    417453          $url = sprintf($this->post_types[$type]['public_url'],$post_url); 
    418454          return $escaped ? html::escapeURL($url) : $url; 
    419455     } 
    420  
     456      
    421457     public function setPostType($type,$admin_url,$public_url,$label='') 
    422458     { 
     
    427463          ); 
    428464     } 
    429  
     465      
    430466     public function getPostTypes() 
    431467     { 
     
    433469     } 
    434470     //@} 
    435  
     471      
    436472     /// @name Versions management methods 
    437473     //@{ 
    438474     /** 
    439475     Returns a given $module version. 
    440  
     476      
    441477     @param    module    <b>string</b>  Module name 
    442478     @return   <b>string</b>  Module version 
     
    449485               $strReq = 'SELECT module, version FROM '.$this->prefix.'version'; 
    450486               $rs = $this->con->select($strReq); 
    451  
     487                
    452488               while ($rs->fetch()) { 
    453489                    $this->versions[$rs->module] = $rs->version; 
    454490               } 
    455491          } 
    456  
     492           
    457493          if (isset($this->versions[$module])) { 
    458494               return $this->versions[$module]; 
     
    461497          } 
    462498     } 
    463  
     499      
    464500     /** 
    465501     Sets $version to given $module. 
    466  
     502      
    467503     @param    module    <b>string</b>  Module name 
    468504     @param    version   <b>string</b>  Module version 
     
    471507     { 
    472508          $cur_version = $this->getVersion($module); 
    473  
     509           
    474510          $cur = $this->con->openCursor($this->prefix.'version'); 
    475511          $cur->module = (string) $module; 
    476512          $cur->version = (string) $version; 
    477  
     513           
    478514          if ($cur_version === null) { 
    479515               $cur->insert(); 
     
    481517               $cur->update("WHERE module='".$this->con->escape($module)."'"); 
    482518          } 
    483  
     519           
    484520          $this->versions[$module] = $version; 
    485521     } 
    486  
     522      
    487523     /** 
    488524     Removes given $module version entry. 
    489  
     525      
    490526     @param    module    <b>string</b>  Module name 
    491527     */ 
     
    495531          'DELETE FROM '.$this->prefix.'version '. 
    496532          "WHERE module = '".$this->con->escape($module)."' "; 
    497  
     533           
    498534          $this->con->execute($strReq); 
    499  
     535           
    500536          if (is_array($this->versions)) { 
    501537               unset($this->versions[$module]); 
    502538          } 
    503539     } 
    504  
     540      
    505541     //@} 
    506  
     542      
    507543     /// @name Users management methods 
    508544     //@{ 
    509545     /** 
    510546     Returns a user by its ID. 
    511  
     547      
    512548     @param    id        <b>string</b>       User ID 
    513549     @return   <b>record</b> 
     
    516552     { 
    517553          $params['user_id'] = $id; 
    518  
     554           
    519555          return $this->getUsers($params); 
    520556     } 
    521  
     557      
    522558     /** 
    523559     Returns a users list. <b>$params</b> is an array with the following 
    524560     optionnal parameters: 
    525  
     561      
    526562      - <var>q</var>: search string (on user_id, user_name, user_firstname) 
    527563      - <var>user_id</var>: user ID 
    528564      - <var>order</var>: ORDER BY clause (default: user_id ASC) 
    529565      - <var>limit</var>: LIMIT clause (should be an array ![limit,offset]) 
    530  
     566      
    531567     @param    params         <b>array</b>        Parameters 
    532568     @param    count_only     <b>boolean</b>      Only counts results 
     
    553589               'WHERE NULL IS NULL '; 
    554590          } 
    555  
     591           
    556592          if (!empty($params['q'])) { 
    557593               $q = $this->con->escape(str_replace('*','%',strtolower($params['q']))); 
     
    562598                    ') '; 
    563599          } 
    564  
     600           
    565601          if (!empty($params['user_id'])) { 
    566602               $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."' "; 
    567603          } 
    568  
     604           
    569605          if (!$count_only) { 
    570606               $strReq .= 'GROUP BY U.user_id,user_super,user_status,user_pwd,user_change_pwd,'. 
    571607               'user_name,user_firstname,user_displayname,user_email,user_url,'. 
    572608               'user_desc, user_lang,user_tz,user_post_status,user_options '; 
    573  
     609                
    574610               if (!empty($params['order']) && !$count_only) { 
    575611                    $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' '; 
     
    578614               } 
    579615          } 
    580  
     616           
    581617          if (!$count_only && !empty($params['limit'])) { 
    582618               $strReq .= $this->con->limit($params['limit']); 
    583619          } 
    584  
     620           
    585621          $rs = $this->con->select($strReq); 
    586622          $rs->extend('rsExtUser'); 
    587623          return $rs; 
    588624     } 
    589  
     625      
    590626     /** 
    591627     Create a new user. Takes a cursor as input and returns the new user ID. 
    592  
     628      
    593629     @param    cur       <b>cursor</b>       User cursor 
    594630     @return   <b>string</b> 
     
    599635               throw new Exception(__('You are not an administrator')); 
    600636          } 
    601  
     637           
    602638          if ($cur->user_id == '') { 
    603639               throw new Exception(__('No user ID given')); 
    604640          } 
    605  
     641           
    606642          if ($cur->user_pwd == '') { 
    607643               throw new Exception(__('No password given')); 
    608644          } 
    609  
     645           
    610646          $this->getUserCursor($cur); 
    611  
     647           
    612648          if ($cur->user_creadt === null) { 
    613649               $cur->user_creadt = date('Y-m-d H:i:s'); 
    614650          } 
    615  
     651           
    616652          $cur->insert(); 
    617  
     653           
    618654          $this->auth->afterAddUser($cur); 
    619  
     655           
    620656          return $cur->user_id; 
    621657     } 
    622  
     658      
    623659     /** 
    624660     Updates an existing user. Returns the user ID. 
    625  
     661      
    626662     @param    id        <b>string</b>       User ID 
    627663     @param    cur       <b>cursor</b>       User cursor 
     
    631667     { 
    632668          $this->getUserCursor($cur); 
    633  
     669           
    634670          if (($cur->user_id !== null || $id != $this->auth->userID()) && 
    635671          !$this->auth->isSuperAdmin()) { 
    636672               throw new Exception(__('You are not an administrator')); 
    637673          } 
    638  
     674           
    639675          $cur->update("WHERE user_id = '".$this->con->escape($id)."' "); 
    640  
     676           
    641677          $this->auth->afterUpdUser($id,$cur); 
    642  
     678           
    643679          if ($cur->user_id !== null) { 
    644680               $id = $cur->user_id; 
    645681          } 
    646  
     682           
    647683          # Updating all user's blogs 
    648684          $rs = $this->con->select( 
     
    650686               "WHERE user_id = '".$this->con->escape($id)."' " 
    651687               ); 
    652  
     688           
    653689          while ($rs->fetch()) { 
    654690               $b = new dcBlog($this,$rs->blog_id); 
     
    656692               unset($b); 
    657693          } 
    658  
     694           
    659695          return $id; 
    660696     } 
    661  
     697      
    662698     /** 
    663699     Deletes a user. 
    664  
     700      
    665701     @param    id        <b>string</b>       User ID 
    666702     */ 
     
    670706               throw new Exception(__('You are not an administrator')); 
    671707          } 
    672  
     708           
    673709          if ($id == $this->auth->userID()) { 
    674710               return; 
    675711          } 
    676  
     712           
    677713          $rs = $this->getUser($id); 
    678  
     714           
    679715          if ($rs->nb_post > 0) { 
    680716               return; 
    681717          } 
    682  
     718           
    683719          $strReq = 'DELETE FROM '.$this->prefix.'user '. 
    684720                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    685  
     721           
    686722          $this->con->execute($strReq); 
    687  
     723           
    688724          $this->auth->afterDelUser($id); 
    689725     } 
    690  
     726      
    691727     /** 
    692728     Checks whether a user exists. 
    693  
     729      
    694730     @param    id        <b>string</b>       User ID 
    695731     @return   <b>boolean</b> 
     
    700736                    'FROM '.$this->prefix.'user '. 
    701737                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    702  
     738           
    703739          $rs = $this->con->select($strReq); 
    704  
     740           
    705741          return !$rs->isEmpty(); 
    706742     } 
    707  
     743      
    708744     /** 
    709745     Returns all user permissions as an array which looks like: 
    710  
     746      
    711747      - [blog_id] 
    712748        - [name] => Blog name 
    713749        - [url] => Blog URL 
    714750        - [p] 
    715           - [permission] => true 
     751          - [permission] => true 
    716752          - ... 
    717  
     753      
    718754     @param    id        <b>string</b>       User ID 
    719755     @return   <b>array</b> 
     
    725761                    'INNER JOIN '.$this->prefix.'blog B ON P.blog_id = B.blog_id '. 
    726762                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    727  
     763           
    728764          $rs = $this->con->select($strReq); 
    729  
     765           
    730766          $res = array(); 
    731  
     767           
    732768          while ($rs->fetch()) 
    733769          { 
     
    738774               ); 
    739775          } 
    740  
     776           
    741777          return $res; 
    742778     } 
    743  
     779      
    744780     /** 
    745781     Sets user permissions. The <var>$perms</var> array looks like: 
    746  
     782      
    747783      - [blog_id] => '|perm1|perm2|' 
    748784      - ... 
    749  
     785      
    750786     @param    id        <b>string</b>       User ID 
    751787     @param    perms     <b>array</b>        Permissions array 
     
    756792               throw new Exception(__('You are not an administrator')); 
    757793          } 
    758  
     794           
    759795          $strReq = 'DELETE FROM '.$this->prefix.'permissions '. 
    760796                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    761  
     797           
    762798          $this->con->execute($strReq); 
    763  
     799           
    764800          foreach ($perms as $blog_id => $p) { 
    765801               $this->setUserBlogPermissions($id, $blog_id, $p, false); 
    766802          } 
    767803     } 
    768  
     804      
    769805     /** 
    770806     Sets user permissions for a given blog. <var>$perms</var> is an array with 
    771807     permissions in values 
    772  
     808      
    773809     @param    id             <b>string</b>       User ID 
    774810     @param    blog_id        <b>string</b>       Blog ID 
     
    781817               throw new Exception(__('You are not an administrator')); 
    782818          } 
    783  
     819           
    784820          $no_perm = empty($perms); 
    785  
     821           
    786822          $perms = '|'.implode('|',array_keys($perms)).'|'; 
    787  
     823           
    788824          $cur = $this->con->openCursor($this->prefix.'permissions'); 
    789  
     825           
    790826          $cur->user_id = (string) $id; 
    791827          $cur->blog_id = (string) $blog_id; 
    792828          $cur->permissions = $perms; 
    793  
     829           
    794830          if ($delete_first || $no_perm) 
    795831          { 
     
    797833                         "WHERE blog_id = '".$this->con->escape($blog_id)."' ". 
    798834                         "AND user_id = '".$this->con->escape($id)."' "; 
    799  
     835                
    800836               $this->con->execute($strReq); 
    801837          } 
    802  
     838           
    803839          if (!$no_perm) { 
    804840               $cur->insert(); 
    805841          } 
    806842     } 
    807  
     843      
    808844     /** 
    809845     Sets a user default blog. This blog will be selected when user log in. 
    810  
     846      
    811847     @param    id             <b>string</b>       User ID 
    812848     @param    blog_id        <b>string</b>       Blog ID 
     
    815851     { 
    816852          $cur = $this->con->openCursor($this->prefix.'user'); 
    817  
     853           
    818854          $cur->user_default_blog = (string) $blog_id; 
    819  
     855           
    820856          $cur->update("WHERE user_id = '".$this->con->escape($id)."'"); 
    821857     } 
    822  
     858      
    823859     private function getUserCursor($cur) 
    824860     { 
     
    827863               throw new Exception(__('User ID must contain at least 2 characters using letters, numbers or symbols.')); 
    828864          } 
    829  
     865           
    830866          if ($cur->user_url !== null && $cur->user_url != '') { 
    831867               if (!preg_match('|^http(s?)://|',$cur->user_url)) { 
     
    833869               } 
    834870          } 
    835  
     871           
    836872          if ($cur->isField('user_pwd')) { 
    837873               if (strlen($cur->user_pwd) < 6) { 
     
    840876               $cur->user_pwd = crypt::hmac(DC_MASTER_KEY,$cur->user_pwd); 
    841877          } 
    842  
     878           
    843879          if ($cur->user_lang !== null && !preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$cur->user_lang)) { 
    844880               throw new Exception(__('Invalid user language code')); 
    845881          } 
    846  
     882           
    847883          if ($cur->user_upddt === null) { 
    848884               $cur->user_upddt = date('Y-m-d H:i:s'); 
    849885          } 
    850  
     886           
    851887          if ($cur->user_options !== null) { 
    852888               $cur->user_options = serialize((array) $cur->user_options); 
    853889          } 
    854890     } 
    855  
     891      
    856892     /** 
    857893     Returns user default settings in an associative array with setting names in 
    858894     keys. 
    859  
     895      
    860896     @return   <b>array</b> 
    861897     */ 
     
    870906     } 
    871907     //@} 
    872  
     908      
    873909     /// @name Blog management methods 
    874910     //@{ 
    875911     /** 
    876912     Returns all blog permissions (users) as an array which looks like: 
    877  
     913      
    878914      - [user_id] 
    879915        - [name] => User name 
     
    882918        - [super] => (true|false) super admin 
    883919        - [p] 
    884           - [permission] => true 
     920          - [permission] => true 
    885921          - ... 
    886  
     922      
    887923     @param    id             <b>string</b>       Blog ID 
    888924     @param    with_super     <b>boolean</b>      Includes super admins in result 
     
    897933          'JOIN '.$this->prefix.'permissions P ON U.user_id = P.user_id '. 
    898934          "WHERE blog_id = '".$this->con->escape($id)."' "; 
    899  
     935           
    900936          if ($with_super) { 
    901937               $strReq .= 
     
    906942               'WHERE user_super = 1 '; 
    907943          } 
    908  
     944           
    909945          $rs = $this->con->select($strReq); 
    910  
     946           
    911947          $res = array(); 
    912  
     948           
    913949          while ($rs->fetch()) 
    914950          { 
     
    922958               ); 
    923959          } 
    924  
     960           
    925961          return $res; 
    926962     } 
    927  
     963      
    928964     /** 
    929965     Returns a blog of given ID. 
    930  
     966      
    931967     @param    id        <b>string</b>       Blog ID 
    932968     @return   <b>record</b> 
     
    935971     { 
    936972          $blog = $this->getBlogs(array('blog_id'=>$id)); 
    937  
     973           
    938974          if ($blog->isEmpty()) { 
    939975               return false; 
    940976          } 
    941  
     977           
    942978          return $blog; 
    943979     } 
    944  
     980      
    945981     /** 
    946982     Returns a record of blogs. <b>$params</b> is an array with the following 
    947983     optionnal parameters: 
    948  
     984      
    949985      - <var>blog_id</var>: Blog ID 
    950986      - <var>q</var>: Search string on blog_id, blog_name and blog_url 
    951987      - <var>limit</var>: limit results 
    952  
     988      
    953989     @param    params         <b>array</b>        Parameters 
    954990     @param    count_only     <b>boolean</b>      Count only results 
     
    959995          $join = '';    // %1$s 
    960996          $where = '';   // %2$s 
    961  
     997           
    962998          if ($count_only) 
    963999          { 
     
    9771013               'WHERE NULL IS NULL '. 
    9781014               '%2$s '; 
    979  
     1015                
    9801016               if (!empty($params['order'])) { 
    9811017                    $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' '; 
     
    9831019                    $strReq .= 'ORDER BY B.blog_id ASC '; 
    9841020               } 
    985  
     1021                
    9861022               if (!empty($params['limit'])) { 
    9871023                    $strReq .= $this->con->limit($params['limit']); 
    9881024               } 
    9891025          } 
    990  
     1026           
    9911027          if ($this->auth->userID() && !$this->auth->isSuperAdmin()) 
    9921028          { 
     
    9991035               $where = 'AND blog_status IN (1,0) '; 
    10001036          } 
    1001  
     1037           
    10021038          if (!empty($params['blog_id'])) { 
    10031039               $where .= "AND B.blog_id = '".$this->con->escape($params['blog_id'])."' "; 
    10041040          } 
    1005  
     1041           
    10061042          if (!empty($params['q'])) { 
    10071043               $params['q'] = strtolower(str_replace('*','%',$params['q'])); 
     
    10131049               ') '; 
    10141050          } 
    1015  
     1051           
    10161052          $strReq = sprintf($strReq,$join,$where); 
    10171053          return $this->con->select($strReq); 
    10181054     } 
    1019  
     1055      
    10201056     /** 
    10211057     Creates a new blog. 
    1022  
     1058      
    10231059     @param    cur            <b>cursor</b>       Blog cursor 
    10241060     */ 
     
    10281064               throw new Exception(__('You are not an administrator')); 
    10291065          } 
    1030  
     1066           
    10311067          $this->getBlogCursor($cur); 
    1032  
     1068           
    10331069          $cur->blog_creadt = date('Y-m-d H:i:s'); 
    10341070          $cur->blog_upddt = date('Y-m-d H:i:s'); 
    10351071          $cur->blog_uid = md5(uniqid()); 
    1036  
     1072           
    10371073          $cur->insert(); 
    10381074     } 
    1039  
     1075      
    10401076     /** 
    10411077     Updates a given blog. 
    1042  
     1078      
    10431079     @param    id        <b>string</b>       Blog ID 
    10441080     @param    cur       <b>cursor</b>       Blog cursor 
     
    10471083     { 
    10481084          $this->getBlogCursor($cur); 
    1049  
     1085           
    10501086          $cur->blog_upddt = date('Y-m-d H:i:s'); 
    1051  
     1087           
    10521088          $cur->update("WHERE blog_id = '".$this->con->escape($id)."'"); 
    10531089     } 
    1054  
     1090      
    10551091     private function getBlogCursor($cur) 
    10561092     { 
     
    10581094               && !preg_match('/^[A-Za-z0-9._-]{2,}$/',$cur->blog_id)) || 
    10591095               (!$cur->blog_id)) { 
    1060                throw new Exception(__('Blog ID must contain at least 2 characters using letters, numbers or symbols.')); 
    1061           } 
    1062  
     1096               throw new Exception(__('Blog ID must contain at least 2 characters using letters, numbers or symbols.'));  
     1097          } 
     1098           
    10631099          if (($cur->blog_name !== null && $cur->blog_name == '') || 
    10641100               (!$cur->blog_name)) { 
    10651101               throw new Exception(__('No blog name')); 
    10661102          } 
    1067  
     1103           
    10681104          if (($cur->blog_url !== null && $cur->blog_url == '') || 
    10691105               (!$cur->blog_url)) { 
    10701106               throw new Exception(__('No blog URL')); 
    10711107          } 
    1072  
     1108           
    10731109          if ($cur->blog_desc !== null) { 
    10741110               $cur->blog_desc = html::clean($cur->blog_desc); 
    10751111          } 
    10761112     } 
    1077  
     1113      
    10781114     /** 
    10791115     Removes a given blog. 
    10801116     @warning This will remove everything related to the blog (posts, 
    10811117     categories, comments, links...) 
    1082  
     1118      
    10831119     @param    id        <b>string</b>       Blog ID 
    10841120     */ 
     
    10881124               throw new Exception(__('You are not an administrator')); 
    10891125          } 
    1090  
     1126           
    10911127          $strReq = 'DELETE FROM '.$this->prefix.'blog '. 
    10921128                    "WHERE blog_id = '".$this->con->escape($id)."' "; 
    1093  
     1129           
    10941130          $this->con->execute($strReq); 
    10951131     } 
    1096  
     1132      
    10971133     /** 
    10981134     Checks if a blog exist. 
    1099  
     1135      
    11001136     @param    id        <b>string</b>       Blog ID 
    11011137     @return   <b>boolean</b> 
     
    11061142                    'FROM '.$this->prefix.'blog '. 
    11071143                    "WHERE blog_id = '".$this->con->escape($id)."' "; 
    1108  
     1144           
    11091145          $rs = $this->con->select($strReq); 
    1110  
     1146           
    11111147          return !$rs->isEmpty(); 
    11121148     } 
    1113  
     1149      
    11141150     /** 
    11151151     Count posts on a blog 
    1116  
     1152      
    11171153     @param    id        <b>string</b>       Blog ID 
    11181154     @param    type      <b>string</b>       Post type 
     
    11241160                    'FROM '.$this->prefix.'post '. 
    11251161                    "WHERE blog_id = '".$this->con->escape($id)."' "; 
    1126  
     1162           
    11271163          if ($type) { 
    11281164               $strReq .= "AND post_type = '".$this->con->escape($type)."' "; 
    11291165          } 
    1130  
     1166           
    11311167          return $this->con->select($strReq)->f(0); 
    11321168     } 
    11331169     //@} 
    1134  
     1170      
    11351171     /// @name HTML Filter methods 
    11361172     //@{ 
     
    11391175     tidy extension is present). If <b>enable_html_filter</b> blog setting is 
    11401176     false, returns not filtered string. 
    1141  
     1177      
    11421178     @param    str  <b>string</b>       String to filter 
    11431179     @return   <b>string</b> Filtered string. 
     
    11481184               return $str; 
    11491185          } 
    1150  
     1186           
    11511187          $filter = new htmlFilter; 
    11521188          $str = trim($filter->apply($str)); 
     
    11541190     } 
    11551191     //@} 
    1156  
     1192      
    11571193     /// @name wiki2xhtml methods 
    11581194     //@{ 
     
    11611197          $this->wiki2xhtml = new wiki2xhtml; 
    11621198     } 
    1163  
     1199      
    11641200     /** 
    11651201     Returns a transformed string with wiki2xhtml. 
    1166  
     1202      
    11671203     @param    str       <b>string</b>       String to transform 
    11681204     @return   <b>string</b>  Transformed string 
     
    11751211          return $this->wiki2xhtml->transform($str); 
    11761212     } 
    1177  
     1213      
    11781214     /** 
    11791215     Inits <var>wiki2xhtml</var> property for blog post. 
     
    11821218     { 
    11831219          $this->initWiki(); 
    1184  
     1220           
    11851221          $this->wiki2xhtml->setOpts(array( 
    11861222               'active_title' => 1, 
     
    12141250               'note_str' => '<div class="footnotes"><h4>Notes</h4>%s</div>' 
    12151251          )); 
    1216  
     1252           
    12171253          $this->wiki2xhtml->registerFunction('url:post',array($this,'wikiPostLink')); 
    1218  
     1254           
    12191255          # --BEHAVIOR-- coreWikiPostInit 
    12201256          $this->callBehavior('coreInitWikiPost',$this->wiki2xhtml); 
    12211257     } 
    1222  
     1258      
    12231259     /** 
    12241260     Inits <var>wiki2xhtml</var> property for simple blog comment (basic syntax). 
     
    12271263     { 
    12281264          $this->initWiki(); 
    1229  
     1265           
    12301266          $this->wiki2xhtml->setOpts(array( 
    12311267               'active_title' => 0, 
     
    12561292               'active_fr_syntax' => 0 
    12571293          )); 
    1258  
     1294           
    12591295          # --BEHAVIOR-- coreInitWikiSimpleComment 
    12601296          $this->callBehavior('coreInitWikiSimpleComment',$this->wiki2xhtml); 
    12611297     } 
    1262  
     1298      
    12631299     /** 
    12641300     Inits <var>wiki2xhtml</var> property for blog comment. 
     
    12671303     { 
    12681304          $this->initWiki(); 
    1269  
     1305           
    12701306          $this->wiki2xhtml->setOpts(array( 
    12711307               'active_title' => 0, 
     
    12961332               'active_fr_syntax' => 0 
    12971333          )); 
    1298  
     1334           
    12991335          # --BEHAVIOR-- coreInitWikiComment 
    13001336          $this->callBehavior('coreInitWikiComment',$this->wiki2xhtml); 
    13011337     } 
    1302  
     1338      
    13031339     public function wikiPostLink($url,$content) 
    13041340     { 
    1305           if (!($this->blog instanceof dcBlog)) { 
     1341          if (!($this->blog instanceof dcBlog)) {  
    13061342               return array(); 
    13071343          } 
    1308  
     1344           
    13091345          $post_id = abs((integer) substr($url,5)); 
    13101346          if (!$post_id) { 
    13111347               return array(); 
    13121348          } 
    1313  
     1349           
    13141350          $post = $this->blog->getPosts(array('post_id'=>$post_id)); 
    13151351          if ($post->isEmpty()) { 
    13161352               return array(); 
    13171353          } 
    1318  
     1354           
    13191355          $res = array('url' => $post->getURL()); 
    13201356          $post_title = $post->post_title; 
    1321  
     1357           
    13221358          if ($content != $url) { 
    13231359               $res['title'] = html::escapeHTML($post->post_title); 
    13241360          } 
    1325  
     1361           
    13261362          if ($content == '' || $content == $url) { 
    13271363               $res['content'] = html::escapeHTML($post->post_title); 
    13281364          } 
    1329  
     1365           
    13301366          if ($post->post_lang) { 
    13311367               $res['lang'] = $post->post_lang; 
    13321368          } 
    1333  
     1369           
    13341370          return $res; 
    13351371     } 
    13361372     //@} 
    1337  
     1373      
    13381374     /// @name Maintenance methods 
    13391375     //@{ 
     
    13411377     Creates default settings for active blog. Optionnal parameter 
    13421378     <var>defaults</var> replaces default params while needed. 
    1343  
     1379      
    13441380     @param    defaults       <b>array</b>   Default parameters 
    13451381     */ 
     
    14261462               ); 
    14271463          } 
    1428  
     1464           
    14291465          $settings = new dcSettings($this,null); 
    14301466          $settings->addNamespace('system'); 
    1431  
     1467           
    14321468          foreach ($defaults as $v) { 
    14331469               $settings->system->put($v[0],$v[2],$v[1],$v[3],false,true); 
    14341470          } 
    14351471     } 
    1436  
     1472      
    14371473     /** 
    14381474     Recreates entries search engine index. 
    1439  
     1475      
    14401476     @param    start     <b>integer</b>      Start entry index 
    14411477     @param    limit     <b>integer</b>      Number of entry to index 
    1442  
     1478      
    14431479     @return   <b>integer</b>      <var>$start</var> and <var>$limit</var> sum 
    14441480     */ 
     
    14491485          $rs = $this->con->select($strReq); 
    14501486          $count = $rs->f(0); 
    1451  
     1487           
    14521488          $strReq = 'SELECT post_id, post_title, post_excerpt_xhtml, post_content_xhtml '. 
    14531489                    'FROM '.$this->prefix.'post '; 
    1454  
     1490           
    14551491          if ($start !== null && $limit !== null) { 
    14561492               $strReq .= $this->con->limit($start,$limit); 
    14571493          } 
    1458  
     1494           
    14591495          $rs = $this->con->select($strReq,true); 
    1460  
     1496           
    14611497          $cur = $this->con->openCursor($this->prefix.'post'); 
    1462  
     1498           
    14631499          while ($rs->fetch()) 
    14641500          { 
    14651501               $words = $rs->post_title.' '. $rs->post_excerpt_xhtml.' '. 
    14661502               $rs->post_content_xhtml; 
    1467  
     1503                
    14681504               $cur->post_words = implode(' ',text::splitWords($words)); 
    14691505               $cur->update('WHERE post_id = '.(integer) $rs->post_id); 
    14701506               $cur->clean(); 
    14711507          } 
    1472  
     1508           
    14731509          if ($start+$limit > $count) { 
    14741510               return null; 
     
    14761512          return $start+$limit; 
    14771513     } 
    1478  
     1514      
    14791515     /** 
    14801516     Recreates comments search engine index. 
    1481  
     1517      
    14821518     @param    start     <b>integer</b>      Start comment index 
    14831519     @param    limit     <b>integer</b>      Number of comments to index 
    1484  
     1520      
    14851521     @return   <b>integer</b>      <var>$start</var> and <var>$limit</var> sum 
    14861522     */ 
     
    14911527          $rs = $this->con->select($strReq); 
    14921528          $count = $rs->f(0); 
    1493  
     1529           
    14941530          $strReq = 'SELECT comment_id, comment_content '. 
    14951531                    'FROM '.$this->prefix.'comment '; 
    1496  
     1532           
    14971533          if ($start !== null && $limit !== null) { 
    14981534               $strReq .= $this->con->limit($start,$limit); 
    14991535          } 
    1500  
     1536           
    15011537          $rs = $this->con->select($strReq); 
    1502  
     1538           
    15031539          $cur = $this->con->openCursor($this->prefix.'comment'); 
    1504  
     1540           
    15051541          while ($rs->fetch()) 
    15061542          { 
     
    15091545               $cur->clean(); 
    15101546          } 
    1511  
     1547           
    15121548          if ($start+$limit > $count) { 
    15131549               return null; 
     
    15151551          return $start+$limit; 
    15161552     } 
    1517  
     1553      
    15181554     /** 
    15191555     Reinits nb_comment and nb_trackback in post table. 
     
    15211557     public function countAllComments() 
    15221558     { 
    1523  
     1559      
    15241560          $updCommentReq = 'UPDATE '.$this->prefix.'post P '. 
    15251561               'SET nb_comment = ('. 
     
    15371573          $this->con->execute($updTrackbackReq); 
    15381574     } 
    1539  
     1575      
    15401576     /** 
    15411577     Empty templates cache directory 
     
    15501586     /** 
    15511587      Return elapsed time since script has been started 
    1552       @param     $mtime <b>float</b> timestamp (microtime format) to evaluate delta from 
    1553                                           current time is taken if null 
    1554       @return <b>float</b>          elapsed time 
     1588      @param   $mtime <b>float</b> timestamp (microtime format) to evaluate delta from 
     1589                                     current time is taken if null 
     1590      @return <b>float</b>        elapsed time 
    15551591      */ 
    15561592     public function getElapsedTime ($mtime=null) { 
  • inc/prepend.php

    r2683 r2715  
    7878$__autoload['context']                  = dirname(__FILE__).'/public/lib.tpl.context.php'; 
    7979$__autoload['dcUrlHandlers']            = dirname(__FILE__).'/public/lib.urlhandlers.php'; 
     80$__autoload['dcAdminURL']            = dirname(__FILE__).'/admin/lib.dc.adminurl.php'; 
    8081$__autoload['dcPostsActionsPage']            = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; 
    8182$__autoload['dcCommentsActionsPage']              = dirname(__FILE__).'/admin/actions/class.dcactioncomments.php'; 
  • inc/prepend.php

    r2711 r2715  
    1515 
    1616/* ------------------------------------------------------------------------------------------- */ 
    17 #  ClearBricks, DotClear classes auto-loader 
     17#  ClearBricks, Twig, DotClear classes auto-loader 
    1818if (@is_dir('/usr/lib/clearbricks')) { 
    1919     define('CLEARBRICKS_PATH','/usr/lib/clearbricks'); 
    20 } elseif (is_dir(dirname(__FILE__).'/libs/clearbricks')) { 
    21      define('CLEARBRICKS_PATH',dirname(__FILE__).'/libs/clearbricks'); 
     20} elseif (is_dir(dirname(__FILE__).'/../vendor/dotclear/clearbricks')) { 
     21     define('CLEARBRICKS_PATH',dirname(__FILE__).'/../vendor/dotclear/clearbricks'); 
    2222} elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) { 
    2323     define('CLEARBRICKS_PATH',$_SERVER['CLEARBRICKS_PATH']); 
     
    2929 
    3030require CLEARBRICKS_PATH.'/_common.php'; 
    31 $__autoload['dcCore']        = dirname(__FILE__).'/core/class.dc.core.php'; 
    32 $__autoload['dcAuth']        = dirname(__FILE__).'/core/class.dc.auth.php'; 
    33 $__autoload['dcBlog']        = dirname(__FILE__).'/core/class.dc.blog.php'; 
    34 $__autoload['dcCategories']  = dirname(__FILE__).'/core/class.dc.categories.php'; 
    35 $__autoload['dcError']       = dirname(__FILE__).'/core/class.dc.error.php'; 
    36 $__autoload['dcMeta']        = dirname(__FILE__).'/core/class.dc.meta.php'; 
    37 $__autoload['dcMedia']       = dirname(__FILE__).'/core/class.dc.media.php'; 
    38 $__autoload['dcPostMedia']   = dirname(__FILE__).'/core/class.dc.postmedia.php'; 
    39 $__autoload['dcModules']     = dirname(__FILE__).'/core/class.dc.modules.php'; 
    40 $__autoload['dcPlugins']     = dirname(__FILE__).'/core/class.dc.plugins.php'; 
    41 $__autoload['dcThemes']      = dirname(__FILE__).'/core/class.dc.themes.php'; 
    42 $__autoload['dcRestServer']  = dirname(__FILE__).'/core/class.dc.rest.php'; 
    43 $__autoload['dcNamespace']   = dirname(__FILE__).'/core/class.dc.namespace.php'; 
    44 $__autoload['dcSettings']    = dirname(__FILE__).'/core/class.dc.settings.php'; 
    45 $__autoload['dcTrackback']   = dirname(__FILE__).'/core/class.dc.trackback.php'; 
    46 $__autoload['dcUpdate']      = dirname(__FILE__).'/core/class.dc.update.php'; 
    47 $__autoload['dcUtils']       = dirname(__FILE__).'/core/class.dc.utils.php'; 
    48 $__autoload['dcXmlRpc']      = dirname(__FILE__).'/core/class.dc.xmlrpc.php'; 
    49 $__autoload['dcLog']         = dirname(__FILE__).'/core/class.dc.log.php'; 
    50 $__autoload['dcWorkspace']   = dirname(__FILE__).'/core/class.dc.workspace.php'; 
    51 $__autoload['dcPrefs']       = dirname(__FILE__).'/core/class.dc.prefs.php'; 
    52 $__autoload['dcStore']       = dirname(__FILE__).'/core/class.dc.store.php'; 
    53 $__autoload['dcStoreReader'] = dirname(__FILE__).'/core/class.dc.store.reader.php'; 
    54 $__autoload['dcStoreParser'] = dirname(__FILE__).'/core/class.dc.store.parser.php'; 
    55 $__autoload['dcFavorites']   = dirname(__FILE__).'/admin/class.dc.favorites.php'; 
    56  
    57 $__autoload['rsExtPost']    = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
    58 $__autoload['rsExtComment'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
    59 $__autoload['rsExtDates']   = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
    60 $__autoload['rsExtUser']    = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
    61  
    62 $__autoload['dcMenu']            = dirname(__FILE__).'/admin/class.dc.menu.php'; 
    63 $__autoload['dcPage']            = dirname(__FILE__).'/admin/lib.dc.page.php'; 
    64 $__autoload['adminGenericList']  = dirname(__FILE__).'/admin/lib.pager.php'; 
    65 $__autoload['adminPostList']     = dirname(__FILE__).'/admin/lib.pager.php'; 
    66 $__autoload['adminPostMiniList'] = dirname(__FILE__).'/admin/lib.pager.php'; 
    67 $__autoload['adminCommentList']  = dirname(__FILE__).'/admin/lib.pager.php'; 
    68 $__autoload['adminUserList']     = dirname(__FILE__).'/admin/lib.pager.php'; 
    69 $__autoload['dcPager']           = dirname(__FILE__).'/admin/lib.pager.php'; 
    70 $__autoload['dcAdminCombos']     = dirname(__FILE__).'/admin/lib.admincombos.php'; 
    71 $__autoload['adminModulesList']  = dirname(__FILE__).'/admin/lib.moduleslist.php'; 
    72 $__autoload['adminThemesList']   = dirname(__FILE__).'/admin/lib.moduleslist.php'; 
     31$__autoload['dcCore']                   = dirname(__FILE__).'/core/class.dc.core.php'; 
     32$__autoload['dcAuth']                   = dirname(__FILE__).'/core/class.dc.auth.php'; 
     33$__autoload['dcBlog']                   = dirname(__FILE__).'/core/class.dc.blog.php'; 
     34$__autoload['dcCategories']             = dirname(__FILE__).'/core/class.dc.categories.php'; 
     35$__autoload['dcError']                  = dirname(__FILE__).'/core/class.dc.error.php'; 
     36$__autoload['dcMeta']                   = dirname(__FILE__).'/core/class.dc.meta.php'; 
     37$__autoload['dcMedia']                  = dirname(__FILE__).'/core/class.dc.media.php'; 
     38$__autoload['dcPostMedia']                   = dirname(__FILE__).'/core/class.dc.postmedia.php'; 
     39$__autoload['dcModules']                = dirname(__FILE__).'/core/class.dc.modules.php'; 
     40$__autoload['dcPlugins']                = dirname(__FILE__).'/core/class.dc.plugins.php'; 
     41$__autoload['dcThemes']                 = dirname(__FILE__).'/core/class.dc.themes.php'; 
     42$__autoload['dcRestServer']             = dirname(__FILE__).'/core/class.dc.rest.php'; 
     43$__autoload['dcNamespace']              = dirname(__FILE__).'/core/class.dc.namespace.php'; 
     44$__autoload['dcSettings']               = dirname(__FILE__).'/core/class.dc.settings.php'; 
     45$__autoload['dcTrackback']              = dirname(__FILE__).'/core/class.dc.trackback.php'; 
     46$__autoload['dcUpdate']                 = dirname(__FILE__).'/core/class.dc.update.php'; 
     47$__autoload['dcUtils']                  = dirname(__FILE__).'/core/class.dc.utils.php'; 
     48$__autoload['dcXmlRpc']                 = dirname(__FILE__).'/core/class.dc.xmlrpc.php'; 
     49$__autoload['dcLog']                    = dirname(__FILE__).'/core/class.dc.log.php'; 
     50$__autoload['dcWorkspace']              = dirname(__FILE__).'/core/class.dc.workspace.php'; 
     51$__autoload['dcPrefs']                  = dirname(__FILE__).'/core/class.dc.prefs.php'; 
     52$__autoload['dcTwigPage']               = dirname(__FILE__).'/core/class.dc.twig.page.php'; 
     53$__autoload['dcStore']             = dirname(__FILE__).'/core/class.dc.store.php'; 
     54$__autoload['dcStoreReader']       = dirname(__FILE__).'/core/class.dc.store.reader.php'; 
     55$__autoload['dcStoreParser']       = dirname(__FILE__).'/core/class.dc.store.parser.php'; 
     56$__autoload['dcFavorites']              = dirname(__FILE__).'/admin/class.dc.favorites.php'; 
     57 
     58$__autoload['rsExtPost']                = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
     59$__autoload['rsExtComment']             = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
     60$__autoload['rsExtDates']               = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
     61$__autoload['rsExtUser']                = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
     62 
     63$__autoload['dcAdminContext']                = dirname(__FILE__).'/admin/class.dc.admincontext.php'; 
     64$__autoload['dcMenu']                   = dirname(__FILE__).'/admin/class.dc.menu.php'; 
     65$__autoload['dcPage']                   = dirname(__FILE__).'/admin/lib.dc.page.php'; 
     66$__autoload['adminGenericList']         = dirname(__FILE__).'/admin/lib.pager.php'; 
     67$__autoload['adminPostList']            = dirname(__FILE__).'/admin/lib.pager.php'; 
     68$__autoload['adminPostMiniList']        = dirname(__FILE__).'/admin/lib.pager.php'; 
     69$__autoload['adminCommentList']         = dirname(__FILE__).'/admin/lib.pager.php'; 
     70$__autoload['adminUserList']            = dirname(__FILE__).'/admin/lib.pager.php'; 
     71$__autoload['dcPager']        = dirname(__FILE__).'/admin/lib.pager.php'; 
     72$__autoload['dcAdminCombos']            = dirname(__FILE__).'/admin/lib.admincombos.php'; 
     73$__autoload['adminModulesList']              = dirname(__FILE__).'/admin/lib.moduleslist.php'; 
     74$__autoload['adminThemesList']               = dirname(__FILE__).'/admin/lib.moduleslist.php'; 
    7375$__autoload['dcThemeConfig']     = dirname(__FILE__).'/admin/lib.themeconfig.php'; 
    7476 
    75 $__autoload['dcTemplate']            = dirname(__FILE__).'/public/class.dc.template.php'; 
    76 $__autoload['context']               = dirname(__FILE__).'/public/lib.tpl.context.php'; 
    77 $__autoload['dcUrlHandlers']         = dirname(__FILE__).'/public/lib.urlhandlers.php'; 
     77$__autoload['dcTemplate']               = dirname(__FILE__).'/public/class.dc.template.php'; 
     78$__autoload['context']                  = dirname(__FILE__).'/public/lib.tpl.context.php'; 
     79$__autoload['dcUrlHandlers']            = dirname(__FILE__).'/public/lib.urlhandlers.php'; 
    7880$__autoload['dcAdminURL']            = dirname(__FILE__).'/admin/lib.dc.adminurl.php'; 
    79 $__autoload['dcPostsActionsPage']    = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; 
    80 $__autoload['dcCommentsActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcactioncomments.php'; 
    81 $__autoload['dcActionsPage']         = dirname(__FILE__).'/admin/actions/class.dcaction.php'; 
     81$__autoload['dcPostsActionsPage']            = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; 
     82$__autoload['dcCommentsActionsPage']              = dirname(__FILE__).'/admin/actions/class.dcactioncomments.php'; 
     83$__autoload['dcActionsPage']            = dirname(__FILE__).'/admin/actions/class.dcaction.php'; 
     84$__autoload['dcForm']              = dirname(__FILE__).'/admin/class.dc.form.php'; 
     85$__autoload['dcFormExtension']               = dirname(__FILE__).'/admin/class.dc.form.php'; 
     86$__autoload['dcTabExtension']           = dirname(__FILE__).'/admin/class.dc.tab.php'; 
     87$__autoload['dcItemList']               = dirname(__FILE__).'/admin/class.dc.list.php'; 
     88$__autoload['dcListFetcher']            = dirname(__FILE__).'/admin/class.dc.list.php'; 
     89 
     90foreach (array('dcFilterSet', 'dcFilter','dcFilterCombo','dcFilterText','dcFilterBoolean') as $c) { 
     91     $__autoload[$c] = dirname(__FILE__).'/admin/class.dc.filter.php'; 
     92} 
    8293 
    8394# Clearbricks extensions 
    8495html::$absolute_regs[] = '/(<param\s+name="movie"\s+value=")(.*?)(")/msu'; 
    8596html::$absolute_regs[] = '/(<param\s+name="FlashVars"\s+value=".*?(?:mp3|flv)=)(.*?)(&|")/msu'; 
     97 
     98if (@is_dir('/usr/lib/twig')) { 
     99     define('TWIG_PATH','/usr/lib/Twig'); 
     100} elseif (is_dir(dirname(__FILE__).'/../vendor/twig/twig/lib/Twig')) { 
     101     define('TWIG_PATH',dirname(__FILE__).'/../vendor/twig/twig/lib/Twig'); 
     102} elseif (isset($_SERVER['TWIG_PATH']) && is_dir($_SERVER['TWIG_PATH'])) { 
     103     define('TWIG_PATH',$_SERVER['TWIG_PATH']); 
     104} 
     105 
     106if (!defined('TWIG_PATH') || !is_dir(TWIG_PATH)) { 
     107     exit('No Twig path defined'); 
     108} 
     109require TWIG_PATH.'/Autoloader.php'; 
     110Twig_Autoloader::register(); 
     111 
    86112/* ------------------------------------------------------------------------------------------- */ 
    87113 
     
    140166# Constants 
    141167define('DC_ROOT',path::real(dirname(__FILE__).'/..')); 
    142 define('DC_VERSION','2.7-dev'); 
     168define('DC_VERSION','2.99-dev'); 
    143169define('DC_DIGESTS',dirname(__FILE__).'/digests'); 
    144170define('DC_L10N_ROOT',dirname(__FILE__).'/../locales'); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map