Dotclear


Ignore:
Files:
212 added
14 edited

Legend:

Unmodified
Added
Removed
  • admin/auth.php

    r2852 r2911  
    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 
     
    1414 
    1515# If we have a session cookie, go to index.php 
    16 if (isset($_SESSION['sess_user_id'])) 
    17 { 
    18      $core->adminurl->redirect('admin.home'); 
     16if (isset($_SESSION['sess_user_id'])) { 
     17     http::redirect('index.php'); 
    1918} 
    2019 
     
    2322$dlang = http::getAcceptLanguage(); 
    2423$dlang = ($dlang == '' ? 'en' : $dlang); 
    25 if ($dlang != 'en' && preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$dlang)) 
    26 { 
    27      l10n::lang($dlang); 
     24if ($dlang != 'en' && preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$dlang)) { 
    2825     l10n::set(dirname(__FILE__).'/../locales/'.$dlang.'/main'); 
    2926} 
    30  
    31 $page_url = http::getHost().$_SERVER['REQUEST_URI']; 
    32  
    33 $change_pwd = $core->auth->allowPassChange() && isset($_POST['new_pwd']) && isset($_POST['new_pwd_c']) && isset($_POST['login_data']); 
    34 $login_data = !empty($_POST['login_data']) ? html::escapeHTML($_POST['login_data']) : null; 
    35 $recover = $core->auth->allowPassChange() && !empty($_REQUEST['recover']); 
    36 $safe_mode = !empty($_REQUEST['safe_mode']); 
    37 $akey = $core->auth->allowPassChange() && !empty($_GET['akey']) ? $_GET['akey'] : null; 
    38 $user_id = $user_pwd = $user_key = $user_email = null; 
    39 $err = $msg = null; 
    4027 
    4128# Auto upgrade 
     
    4431     try { 
    4532          if (($changes = dotclearUpgrade($core)) !== false) { 
    46                $msg = __('Dotclear has been upgraded.').'<!-- '.$changes.' -->'; 
    47           } 
    48      } catch (Exception $e) { 
    49           $err = $e->getMessage(); 
    50      } 
    51 } 
    52  
    53 # If we have POST login informations, go throug auth process 
    54 if (!empty($_POST['user_id']) && !empty($_POST['user_pwd'])) 
     33               $_ctx->setAlert(__('Dotclear has been upgraded.').'<!-- '.$changes.' -->'); 
     34          } 
     35     } 
     36     catch (Exception $e) { 
     37          $_ctx->addError($e->getMessage()); 
     38     } 
     39} 
     40 
     41/** 
     42Actions for authentication on admin pages 
     43*/ 
     44class adminPageAuth 
    5545{ 
    56      $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; 
    57      $user_pwd = !empty($_POST['user_pwd']) ? $_POST['user_pwd'] : null; 
    58 } 
    59 # If we have COOKIE login informations, go throug auth process 
    60 elseif (isset($_COOKIE['dc_admin']) && strlen($_COOKIE['dc_admin']) == 104) 
    61 { 
     46     # Send new password from recover email 
     47     public static function send($akey) 
     48     { 
     49          global $core, $_ctx; 
     50           
     51          $_ctx->akey = true; 
     52           
     53          try  { 
     54               $recover_res = $core->auth->recoverUserPassword($akey); 
     55                
     56               $subject = mb_encode_mimeheader('DotClear '.__('Your new password'),'UTF-8','B'); 
     57               $message = 
     58               __('Username:').' '.$recover_res['user_id']."\n". 
     59               __('Password:').' '.$recover_res['new_pass']."\n\n". 
     60               preg_replace('/\?(.*)$/','',http::getHost().$_SERVER['REQUEST_URI']); 
     61                
     62               $headers[] = 'From: dotclear@'.$_SERVER['HTTP_HOST']; 
     63               $headers[] = 'Content-Type: text/plain; charset=UTF-8;'; 
     64                
     65               mail::sendMail($recover_res['user_email'],$subject,$message,$headers); 
     66               $_ctx->setAlert(__('Your new password is in your mailbox.')); 
     67          } 
     68          catch (Exception $e) { 
     69               $_ctx->addError($e->getMessage()); 
     70          } 
     71     } 
     72      
     73     # Authentication process 
     74     public static function process($form,$user_id,$user_pwd,$user_key=null) 
     75     { 
     76          global $core, $_ctx; 
     77           
     78          # We check the user 
     79          $check_user = $core->auth->checkUser($user_id,$user_pwd,$user_key) === true; 
     80           
     81          $cookie_admin = http::browserUID(DC_MASTER_KEY.$user_id. 
     82               crypt::hmac(DC_MASTER_KEY,$user_pwd)).bin2hex(pack('a32',$user_id)); 
     83           
     84          if ($check_user && $core->auth->mustChangePassword()) 
     85          { 
     86               $form->login_data = join('/',array( 
     87                    base64_encode($user_id), 
     88                    $cookie_admin, 
     89                    $form->user_remember == '' ? '0' : '1' 
     90               )); 
     91                
     92               if (!$core->auth->allowPassChange()) { 
     93                    $_ctx->addError(__('You have to change your password before you can login.')); 
     94               } else { 
     95                    $_ctx->addError(__('In order to login, you have to change your password now.')); 
     96                    $_ctx->change_pwd = true; 
     97               } 
     98          } 
     99          elseif ($check_user && $form->safe_mode != '' && !$core->auth->isSuperAdmin())  
     100          { 
     101               $_ctx->addError(__('Safe Mode can only be used for super administrators.')); 
     102          } 
     103          elseif ($check_user) 
     104          { 
     105               $core->session->start(); 
     106               $_SESSION['sess_user_id'] = $user_id; 
     107               $_SESSION['sess_browser_uid'] = http::browserUID(DC_MASTER_KEY); 
     108                
     109               if ($form->blog != '') { 
     110                    $_SESSION['sess_blog_id'] = $form->blog; 
     111               } 
     112                
     113               if ($form->safe_mode != '' && $core->auth->isSuperAdmin()) { 
     114                    $_SESSION['sess_safe_mode'] = true; 
     115               } 
     116                
     117               if ($form->user_remember != '') { 
     118                    setcookie('dc_admin',$cookie_admin,strtotime('+15 days'),'','',DC_ADMIN_SSL); 
     119               } 
     120                
     121               http::redirect('index.php'); 
     122          } 
     123          else 
     124          { 
     125               if (isset($_COOKIE['dc_admin'])) { 
     126                    unset($_COOKIE['dc_admin']); 
     127                    setcookie('dc_admin',false,-600,'','',DC_ADMIN_SSL); 
     128               } 
     129               $_ctx->addError(__('Wrong username or password')); 
     130          } 
     131     } 
     132      
     133     # Login form action 
     134     public static function login($form) 
     135     { 
     136          global $_ctx; 
     137           
     138          if ($form->user_id != '' && $form->user_pwd != '') { 
     139               self::process($form,$form->user_id,$form->user_pwd); 
     140          } 
     141           
     142          # Send post values to form 
     143          $form->user_id = $form->user_id; 
     144     } 
     145 
     146     # Recover password form action 
     147     public static function recover($form) 
     148     { 
     149          global $core, $_ctx; 
     150           
     151          if ($form->user_id == '' || $form->user_email == '') { 
     152               return; 
     153          } 
     154           
     155          $user_id = $form->user_id; 
     156          $user_email = $form->user_email; 
     157          $page_url = http::getHost().$_SERVER['REQUEST_URI']; 
     158           
     159          try { 
     160               $recover_key = $core->auth->setRecoverKey($user_id,$user_email); 
     161                
     162               $subject = mail::B64Header('DotClear '.__('Password reset')); 
     163               $message = 
     164               __('Someone has requested to reset the password for the following site and username.')."\n\n". 
     165               $page_url."\n".__('Username:').' '.$user_id."\n\n". 
     166               __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.')."\n". 
     167               $page_url.'?akey='.$recover_key; 
     168                
     169               $headers[] = 'From: '.(defined('DC_ADMIN_MAILFROM') && DC_ADMIN_MAILFROM ? DC_ADMIN_MAILFROM : 'dotclear@local'); 
     170               $headers[] = 'Content-Type: text/plain; charset=UTF-8;'; 
     171                
     172               mail::sendMail($user_email,$subject,$message,$headers); 
     173               $_ctx->setAlert(sprintf(__('The e-mail was sent successfully to %s.'),$user_email)); 
     174          } 
     175          catch (Exception $e) { 
     176               $_ctx->addError($e->getMessage()); 
     177          } 
     178           
     179          # Send post values to form 
     180          $form->user_id = $form->user_id; 
     181          $form->user_email = $form->user_email; 
     182     } 
     183 
     184     # Change password form action 
     185     public static function change($form) 
     186     { 
     187          global $core, $_ctx; 
     188           
     189          if ($form->login_data) { 
     190               return; 
     191          } 
     192          $_ctx->change_pwd = true; 
     193           
     194          $new_pwd = (string) $form->new_pwd; 
     195          $new_pwd_c = (string) $form->new_pwd_c; 
     196           
     197          try { 
     198               $tmp_data = explode('/',$form->login_data); 
     199               if (count($tmp_data) != 3) { 
     200                    throw new Exception(); 
     201               } 
     202               $data = array( 
     203                    'user_id'=>base64_decode($tmp_data[0]), 
     204                    'cookie_admin'=>$tmp_data[1], 
     205                    'user_remember'=>$tmp_data[2]=='1' 
     206               ); 
     207               if ($data['user_id'] === false) { 
     208                    throw new Exception(); 
     209               } 
     210                
     211               # Check login informations 
     212               $check_user = false; 
     213               if (isset($data['cookie_admin']) && strlen($data['cookie_admin']) == 104) 
     214               { 
     215                    $user_id = substr($data['cookie_admin'],40); 
     216                    $user_id = @unpack('a32',@pack('H*',$user_id)); 
     217                    if (is_array($user_id)) 
     218                    { 
     219                         $user_id = $user_id[1]; 
     220                         $user_key = substr($data['cookie_admin'],0,40); 
     221                         $check_user = $core->auth->checkUser($user_id,null,$user_key) === true; 
     222                    } 
     223               } 
     224                
     225               if (!$core->auth->allowPassChange() || !$check_user) { 
     226                    $_ctx->change_pwd = false; 
     227                    throw new Exception(); 
     228               } 
     229                
     230               if ($new_pwd != $new_pwd_c) { 
     231                    throw new Exception(__("Passwords don't match")); 
     232               } 
     233                
     234               if ($core->auth->checkUser($user_id,$new_pwd) === true) { 
     235                    throw new Exception(__("You didn't change your password.")); 
     236               } 
     237                
     238               $cur = $core->con->openCursor($core->prefix.'user'); 
     239               $cur->user_change_pwd = 0; 
     240               $cur->user_pwd = $new_pwd; 
     241               $core->updUser($core->auth->userID(),$cur); 
     242                
     243               $core->session->start(); 
     244               $_SESSION['sess_user_id'] = $user_id; 
     245               $_SESSION['sess_browser_uid'] = http::browserUID(DC_MASTER_KEY); 
     246                
     247               if ($data['user_remember']) { 
     248                    setcookie('dc_admin',$data['cookie_admin'],strtotime('+15 days'),'','',DC_ADMIN_SSL); 
     249               } 
     250                
     251               http::redirect('index.php'); 
     252          } 
     253          catch (Exception $e) { 
     254               $_ctx->addError($e->getMessage()); 
     255          } 
     256           
     257          # Send post values to form 
     258          $form->login_data = $form->login_data; 
     259     } 
     260} 
     261 
     262# Form fields 
     263$form = new dcForm($core,'auth','auth.php'); 
     264$form 
     265     ->addField( 
     266          new dcFieldText('user_id','',array( 
     267               "label" => __('Username:'), 
     268               "maxlength" => 32))) 
     269     ->addField( 
     270          new dcFieldPassword('user_pwd','',array( 
     271               "label" => __('Password:')))) 
     272     ->addField( 
     273          new dcFieldText('user_email','',array( 
     274               "label" => __('Email:')))) 
     275     ->addField( 
     276          new dcFieldPassword('new_pwd','',array( 
     277               "label" => __('New password:')))) 
     278     ->addField( 
     279          new dcFieldPassword('new_pwd_c','',array( 
     280               "label" => __('Confirm password:')))) 
     281     ->addField( 
     282          new dcFieldCheckbox ('user_remember',1,array( 
     283               "label" => __('Remember my ID on this computer')))) 
     284     ->addField( 
     285          new dcFieldSubmit('auth_login',__('log in'),array( 
     286               'action' => array('adminPageAuth','login')))) 
     287     ->addField( 
     288          new dcFieldSubmit('auth_recover',__('recover'),array( 
     289               'action' => array('adminPageAuth','recover')))) 
     290     ->addField( 
     291          new dcFieldSubmit('auth_change',__('change'),array( 
     292               'action' => array('adminPageAuth','change')))) 
     293     ->addField( 
     294          new dcFieldHidden ('safe_mode','0')) 
     295     ->addField( 
     296          new dcFieldHidden ('recover','0')) 
     297     ->addField( 
     298          new dcFieldHidden ('login_data','')) 
     299     ->addField( 
     300          new dcFieldHidden ('blog','')); 
     301 
     302# Context variables 
     303$_ctx->allow_pass_change = $core->auth->allowPassChange(); 
     304$_ctx->change_pwd = $core->auth->allowPassChange() && $form->new_pwd != '' && $form->new_pwd_c != '' && $form->login_data != ''; 
     305$_ctx->recover = $form->recover = $core->auth->allowPassChange() && !empty($_REQUEST['recover']); 
     306$_ctx->setSafeMode(!empty($_REQUEST['safe_mode']));  
     307$form->safe_mode = !empty($_REQUEST['safe_mode']); 
     308$_ctx->akey = false; 
     309$_ctx->dlang = $dlang; 
     310 
     311# If we have no POST login informations and have COOKIE login informations, go throug auth process 
     312if ($form->user_id == '' && $form->user_pwd == ''  
     313 && isset($_COOKIE['dc_admin']) && strlen($_COOKIE['dc_admin']) == 104) { 
     314 
    62315     # If we have a remember cookie, go through auth process with user_key 
    63316     $user_id = substr($_COOKIE['dc_admin'],40); 
    64317     $user_id = @unpack('a32',@pack('H*',$user_id)); 
    65      if (is_array($user_id)) 
    66      { 
     318      
     319     if (is_array($user_id)) { 
    67320          $user_id = $user_id[1]; 
    68321          $user_key = substr($_COOKIE['dc_admin'],0,40); 
    69           $user_pwd = null; 
    70      } 
    71      else 
    72      { 
    73           $user_id = null; 
    74      } 
    75 } 
    76  
    77 # Recover password 
    78 if ($recover && !empty($_POST['user_id']) && !empty($_POST['user_email'])) 
    79 { 
    80      $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; 
    81      $user_email = !empty($_POST['user_email']) ? $_POST['user_email'] : ''; 
    82      try 
    83      { 
    84           $recover_key = $core->auth->setRecoverKey($user_id,$user_email); 
    85  
    86           $subject = mail::B64Header('DotClear '.__('Password reset')); 
    87           $message = 
    88           __('Someone has requested to reset the password for the following site and username.')."\n\n". 
    89           $page_url."\n".__('Username:').' '.$user_id."\n\n". 
    90           __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.')."\n". 
    91           $page_url.'?akey='.$recover_key; 
    92  
    93           $headers[] = 'From: '.(defined('DC_ADMIN_MAILFROM') && DC_ADMIN_MAILFROM ? DC_ADMIN_MAILFROM : 'dotclear@local'); 
    94           $headers[] = 'Content-Type: text/plain; charset=UTF-8;'; 
    95  
    96           mail::sendMail($user_email,$subject,$message,$headers); 
    97           $msg = sprintf(__('The e-mail was sent successfully to %s.'),$user_email); 
    98      } 
    99      catch (Exception $e) 
    100      { 
    101           $err = $e->getMessage(); 
    102      } 
    103 } 
    104 # Send new password 
    105 elseif ($akey) 
    106 { 
    107      try 
    108      { 
    109           $recover_res = $core->auth->recoverUserPassword($akey); 
    110  
    111           $subject = mb_encode_mimeheader('DotClear '.__('Your new password'),'UTF-8','B'); 
    112           $message = 
    113           __('Username:').' '.$recover_res['user_id']."\n". 
    114           __('Password:').' '.$recover_res['new_pass']."\n\n". 
    115           preg_replace('/\?(.*)$/','',$page_url); 
    116  
    117           $headers[] = 'From: dotclear@'.$_SERVER['HTTP_HOST']; 
    118           $headers[] = 'Content-Type: text/plain; charset=UTF-8;'; 
    119  
    120           mail::sendMail($recover_res['user_email'],$subject,$message,$headers); 
    121           $msg = __('Your new password is in your mailbox.'); 
    122      } 
    123      catch (Exception $e) 
    124      { 
    125           $err = $e->getMessage(); 
    126      } 
    127 } 
    128 # Change password and retry to log 
    129 elseif ($change_pwd) 
    130 { 
    131      try 
    132      { 
    133           $tmp_data = explode('/',$_POST['login_data']); 
    134           if (count($tmp_data) != 3) { 
    135                throw new Exception(); 
    136           } 
    137           $data = array( 
    138                'user_id'=>base64_decode($tmp_data[0]), 
    139                'cookie_admin'=>$tmp_data[1], 
    140                'user_remember'=>$tmp_data[2]=='1' 
    141           ); 
    142           if ($data['user_id'] === false) { 
    143                throw new Exception(); 
    144           } 
    145  
    146      # Check login informations 
    147      $check_user = false; 
    148      if (isset($data['cookie_admin']) && strlen($data['cookie_admin']) == 104) 
    149      { 
    150           $user_id = substr($data['cookie_admin'],40); 
    151           $user_id = @unpack('a32',@pack('H*',$user_id)); 
    152           if (is_array($user_id)) 
    153           { 
    154                $user_id = $user_id[1]; 
    155                $user_key = substr($data['cookie_admin'],0,40); 
    156                $check_user = $core->auth->checkUser($user_id,null,$user_key) === true; 
    157           } 
    158      } 
    159  
    160           if (!$core->auth->allowPassChange() || !$check_user) { 
    161                $change_pwd = false; 
    162                throw new Exception(); 
    163           } 
    164  
    165           if ($_POST['new_pwd'] != $_POST['new_pwd_c']) { 
    166                throw new Exception(__("Passwords don't match")); 
    167           } 
    168  
    169           if ($core->auth->checkUser($user_id,$_POST['new_pwd']) === true) { 
    170                throw new Exception(__("You didn't change your password.")); 
    171           } 
    172  
    173           $cur = $core->con->openCursor($core->prefix.'user'); 
    174           $cur->user_change_pwd = 0; 
    175           $cur->user_pwd = $_POST['new_pwd']; 
    176           $core->updUser($core->auth->userID(),$cur); 
    177  
    178           $core->session->start(); 
    179           $_SESSION['sess_user_id'] = $user_id; 
    180           $_SESSION['sess_browser_uid'] = http::browserUID(DC_MASTER_KEY); 
    181  
    182           if ($data['user_remember']) 
    183           { 
    184                setcookie('dc_admin',$data['cookie_admin'],strtotime('+15 days'),'','',DC_ADMIN_SSL); 
    185           } 
    186  
    187           $core->adminurl->redirect('admin.home'); 
    188      } 
    189      catch (Exception $e) 
    190      { 
    191           $err = $e->getMessage(); 
    192      } 
    193 } 
    194 # Try to log 
    195 elseif ($user_id !== null && ($user_pwd !== null || $user_key !== null)) 
    196 { 
    197      # We check the user 
    198      $check_user = $core->auth->checkUser($user_id,$user_pwd,$user_key,false) === true; 
    199      if ($check_user) { 
    200           $check_perms = $core->auth->findUserBlog() !== false; 
    201      } else { 
    202           $check_perms = false; 
    203      } 
    204  
    205      $cookie_admin = http::browserUID(DC_MASTER_KEY.$user_id. 
    206           crypt::hmac(DC_MASTER_KEY,$user_pwd)).bin2hex(pack('a32',$user_id)); 
    207  
    208      if ($check_perms && $core->auth->mustChangePassword()) 
    209      { 
    210           $login_data = join('/',array( 
    211                base64_encode($user_id), 
    212                $cookie_admin, 
    213                empty($_POST['user_remember'])?'0':'1' 
    214           )); 
    215  
    216           if (!$core->auth->allowPassChange()) { 
    217                $err = __('You have to change your password before you can login.'); 
    218           } else { 
    219                $err = __('In order to login, you have to change your password now.'); 
    220                $change_pwd = true; 
    221           } 
    222      } 
    223      elseif ($check_perms && !empty($_POST['safe_mode']) && !$core->auth->isSuperAdmin()) 
    224      { 
    225           $err = __('Safe Mode can only be used for super administrators.'); 
    226      } 
    227      elseif ($check_perms) 
    228      { 
    229           $core->session->start(); 
    230           $_SESSION['sess_user_id'] = $user_id; 
    231           $_SESSION['sess_browser_uid'] = http::browserUID(DC_MASTER_KEY); 
    232  
    233           if (!empty($_POST['blog'])) { 
    234                $_SESSION['sess_blog_id'] = $_POST['blog']; 
    235           } 
    236  
    237           if (!empty($_POST['safe_mode']) && $core->auth->isSuperAdmin()) { 
    238                $_SESSION['sess_safe_mode'] = true; 
    239           } 
    240  
    241           if (!empty($_POST['user_remember'])) { 
    242                setcookie('dc_admin',$cookie_admin,strtotime('+15 days'),'','',DC_ADMIN_SSL); 
    243           } 
    244  
    245           $core->adminurl->redirect('admin.home'); 
    246      } 
    247      else 
    248      { 
    249           if (isset($_COOKIE['dc_admin'])) { 
    250                unset($_COOKIE['dc_admin']); 
    251                setcookie('dc_admin',false,-600,'','',DC_ADMIN_SSL); 
    252           } 
    253           if ($check_user) { 
    254                $err = __('Insufficient permissions'); 
    255           } else { 
    256                $err = __('Wrong username or password'); 
    257           } 
    258      } 
     322          $user_pwd = ''; 
     323           
     324          adminPageAuth::process($form,$user_id,$user_pwd,$user_key); 
     325     } 
     326} 
     327# If we have an akey, go throug send password process 
     328elseif ($core->auth->allowPassChange() && !empty($_GET['akey'])) { 
     329     adminPageAuth::send($_GET['akey']); 
    259330} 
    260331 
    261332if (isset($_GET['user'])) { 
    262      $user_id = $_GET['user']; 
    263 } 
    264  
    265 header('Content-Type: text/html; charset=UTF-8'); 
    266  
    267 // Prevents Clickjacking as far as possible 
    268 header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ 
    269  
     333     $form->user_id = $_GET['user']; 
     334} 
     335 
     336$form->setup(); 
     337 
     338$core->tpl->display('auth.html.twig'); 
    270339?> 
    271 <!DOCTYPE html> 
    272 <html lang="<?php echo $dlang; ?>"> 
    273 <head> 
    274   <meta charset="UTF-8" /> 
    275   <meta http-equiv="Content-Script-Type" content="text/javascript" /> 
    276   <meta http-equiv="Content-Style-Type" content="text/css" /> 
    277   <meta http-equiv="Content-Language" content="<?php echo $dlang; ?>" /> 
    278   <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" /> 
    279   <meta name="GOOGLEBOT" content="NOSNIPPET" /> 
    280   <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 
    281   <title><?php echo html::escapeHTML(DC_VENDOR_NAME); ?></title> 
    282   <link rel="icon" type="image/png" href="images/favicon96-logout.png" /> 
    283   <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" /> 
    284  
    285  
    286 <?php 
    287 echo dcPage::jsLoadIE7(); 
    288 echo dcPage::jsCommon(); 
    289 ?> 
    290  
    291      <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" /> 
    292  
    293   <?php 
    294   # --BEHAVIOR-- loginPageHTMLHead 
    295   $core->callBehavior('loginPageHTMLHead'); 
    296   ?> 
    297  
    298   <script type="text/javascript"> 
    299   //<![CDATA[ 
    300   $(window).load(function() { 
    301     var uid = $('input[name=user_id]'); 
    302     var upw = $('input[name=user_pwd]'); 
    303     uid.focus(); 
    304  
    305     if (upw.length == 0) { return; } 
    306  
    307     uid.keypress(processKey); 
    308  
    309     function processKey(evt) { 
    310       if (evt.which == 13 && upw.val() == '') { 
    311          upw.focus(); 
    312          return false; 
    313       } 
    314       return true; 
    315     }; 
    316     $.cookie('dc_admin_test_cookie',true); 
    317     if ($.cookie('dc_admin_test_cookie')) { 
    318       $('#cookie_help').hide(); 
    319       $.cookie('dc_admin_test_cookie', '', {'expires': -1}); 
    320     } else { 
    321       $('#cookie_help').show(); 
    322     } 
    323     $('#issue #more').toggleWithLegend($('#issue').children().not('#more')); 
    324   }); 
    325   //]]> 
    326   </script> 
    327 </head> 
    328  
    329 <body id="dotclear-admin" class="auth"> 
    330  
    331 <form action="<?php echo $core->adminurl->get('admin.auth'); ?>" method="post" id="login-screen"> 
    332 <h1 role="banner"><?php echo html::escapeHTML(DC_VENDOR_NAME); ?></h1> 
    333  
    334 <?php 
    335 if ($err) { 
    336      echo '<div class="error" role="alert">'.$err.'</div>'; 
    337 } 
    338 if ($msg) { 
    339      echo '<p class="success" role="alert">'.$msg.'</p>'; 
    340 } 
    341  
    342 if ($akey) 
    343 { 
    344      echo '<p><a href="'.$core->adminurl->get('admin.auth').'">'.__('Back to login screen').'</a></p>'; 
    345 } 
    346 elseif ($recover) 
    347 { 
    348      echo 
    349      '<div class="fieldset" role="main"><h2>'.__('Request a new password').'</h2>'. 
    350      '<p><label for="user_id">'.__('Username:').'</label> '. 
    351      form::field(array('user_id','user_id'),20,32,html::escapeHTML($user_id)).'</p>'. 
    352  
    353      '<p><label for="user_email">'.__('Email:').'</label> '. 
    354      form::field(array('user_email','user_email'),20,255,html::escapeHTML($user_email)).'</p>'. 
    355  
    356      '<p><input type="submit" value="'.__('recover').'" />'. 
    357      form::hidden(array('recover'),1).'</p>'. 
    358      '</div>'. 
    359  
    360      '<div id="issue">'. 
    361      '<p><a href="'.$core->adminurl->get('admin.auth').'">'.__('Back to login screen').'</a></p>'. 
    362      '</div>'; 
    363 } 
    364 elseif ($change_pwd) 
    365 { 
    366      echo 
    367      '<div class="fieldset"><h2>'.__('Change your password').'</h2>'. 
    368      '<p><label for="new_pwd">'.__('New password:').'</label> '. 
    369      form::password(array('new_pwd','new_pwd'),20,255).'</p>'. 
    370  
    371      '<p><label for="new_pwd_c">'.__('Confirm password:').'</label> '. 
    372      form::password(array('new_pwd_c','new_pwd_c'),20,255).'</p>'. 
    373      '</div>'. 
    374  
    375      '<p><input type="submit" value="'.__('change').'" />'. 
    376      form::hidden('login_data',$login_data).'</p>'; 
    377 } 
    378 else 
    379 { 
    380      if (is_callable(array($core->auth,'authForm'))) 
    381      { 
    382           echo $core->auth->authForm($user_id); 
    383      } 
    384      else 
    385      { 
    386           if ($safe_mode) { 
    387                echo '<div class="fieldset" role="main">'; 
    388                echo '<h2>'.__('Safe mode login').'</h2>'; 
    389                echo 
    390                     '<p class="form-note">'. 
    391                     __('This mode allows you to login without activating any of your plugins. This may be useful to solve compatibility problems').'&nbsp;</p>'. 
    392                     '<p class="form-note">'.__('Disable or delete any plugin suspected to cause trouble, then log out and log back in normally.'). 
    393                     '</p>'; 
    394           } 
    395           else { 
    396                echo '<div class="fieldset" role="main">'; 
    397           } 
    398  
    399           echo 
    400           '<p><label for="user_id">'.__('Username:').'</label> '. 
    401           form::field(array('user_id','user_id'),20,32,html::escapeHTML($user_id)).'</p>'. 
    402  
    403           '<p><label for="user_pwd">'.__('Password:').'</label> '. 
    404           form::password(array('user_pwd','user_pwd'),20,255).'</p>'. 
    405  
    406           '<p>'. 
    407           form::checkbox(array('user_remember','user_remember'),1). 
    408           '<label for="user_remember" class="classic">'. 
    409           __('Remember my ID on this computer').'</label></p>'. 
    410  
    411           '<p><input type="submit" value="'.__('log in').'" class="login" /></p>'; 
    412  
    413           if (!empty($_REQUEST['blog'])) { 
    414                echo form::hidden('blog',html::escapeHTML($_REQUEST['blog'])); 
    415           } 
    416           if($safe_mode) { 
    417                echo 
    418                form::hidden('safe_mode',1). 
    419                '</div>'; 
    420           } 
    421           else { 
    422                echo '</div>'; 
    423           } 
    424           echo 
    425           '<p id="cookie_help" class="error">'.__('You must accept cookies in order to use the private area.').'</p>'; 
    426  
    427           echo '<div id="issue">'; 
    428  
    429           if ($safe_mode) { 
    430                echo 
    431                '<p><a href="'.$core->adminurl->get('admin.auth').'" id="normal_mode_link">'.__('Get back to normal authentication').'</a></p>'; 
    432           } else { 
    433                echo '<p id="more"><strong>'.__('Connection issue?').'</strong></p>'; 
    434                if ($core->auth->allowPassChange()) { 
    435                     echo '<p><a href="'.$core->adminurl->get('admin.auth',array('recover' => 1)).'">'.__('I forgot my password').'</a></p>'; 
    436                } 
    437                echo '<p><a href="'.$core->adminurl->get('admin.auth',array('safe_mode' => 1)).'" id="safe_mode_link">'.__('I want to log in in safe mode').'</a></p>'; 
    438           } 
    439  
    440           echo '</div>'; 
    441      } 
    442 } 
    443 ?> 
    444 </form> 
    445 </body> 
    446 </html> 
  • admin/index.php

    r2854 r2911  
    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'; 
     
    2126     try { 
    2227          $core->setUserDefaultBlog($core->auth->userID(),$core->blog->id); 
    23           $core->adminurl->redirect("admin.home"); 
     28          http::redirect('index.php'); 
    2429     } catch (Exception $e) { 
    2530          $core->error->add($e->getMessage()); 
     
    3641          setcookie('dc_admin',false,-600,'','',DC_ADMIN_SSL); 
    3742     } 
    38      $core->adminurl->redirect("admin.auth"); 
     43     http::redirect('auth.php'); 
    3944     exit; 
    4045} 
     
    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('&nbsp;' => ''); 
     144     try { 
     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     $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 # Editor stuff 
    171 $admin_post_behavior = ''; 
    172 if ($core->auth->user_prefs->dashboard->quickentry) { 
    173      if ($core->auth->check('usage,contentadmin',$core->blog->id)) 
    174      { 
    175           $post_format = $core->auth->getOption('post_format'); 
    176           $post_editor = $core->auth->getOption('editor'); 
    177           if ($post_editor && !empty($post_editor[$post_format])) { 
    178                // context is not post because of tags not available 
    179                $admin_post_behavior = $core->callBehavior('adminPostEditor', $post_editor[$post_format], 'quickentry', array('#post_content')); 
    180           } 
    181      } 
    182 } 
    183  
    184 /* DISPLAY 
    185 -------------------------------------------------------- */ 
    186 dcPage::open(__('Dashboard'), 
    187      dcPage::jsLoad('js/_index.js'). 
    188      $admin_post_behavior. 
    189      # --BEHAVIOR-- adminDashboardHeaders 
    190      $core->callBehavior('adminDashboardHeaders'), 
    191      dcPage::breadcrumb( 
    192           array( 
    193           __('Dashboard').' : '.html::escapeHTML($core->blog->name) => '' 
    194           ), 
    195           array('home_link' =>false) 
    196      ) 
    197 ); 
    198  
    199 # Dotclear updates notifications 
    200 if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) 
    201 { 
    202      $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 
    203      $new_v = $updater->check(DC_VERSION); 
    204      $version_info = $new_v ? $updater->getInfoURL() : ''; 
    205  
    206      if ($updater->getNotify() && $new_v) { 
    207           echo 
    208           '<div class="dc-update"><h3>'.sprintf(__('Dotclear %s is available!'),$new_v).'</h3> '. 
    209           '<p><a class="button submit" href="'.$core->adminurl->get("admin.update").'">'.sprintf(__('Upgrade now'),$new_v).'</a> '. 
    210           '<a class="button" href="'.$core->adminurl->get("admin.update", array('hide_msg' => 1)).'">'.__('Remind me later').'</a>'. 
    211           ($version_info ? ' </p>'. 
    212           '<p class="updt-info"><a href="'.$version_info.'">'.__('Information about this version').'</a>' : '').'</p>'. 
    213           '</div>'; 
    214      } 
    215 } 
    216  
    217 if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->getBlogCount() > 1) { 
    218      echo 
    219      '<p><a href="'.$core->adminurl->get("admin.home",array('default_blog' => 1)).'" class="button">'.__('Make this blog my default blog').'</a></p>'; 
    220 } 
    221  
     289# Blog status message 
    222290if ($core->blog->status == 0) { 
    223      echo '<p class="static-msg">'.__('This blog is offline').'.</p>'; 
     291     $_ctx->addMessageStatic(__('This blog is offline')); 
    224292} elseif ($core->blog->status == -1) { 
    225      echo '<p class="static-msg">'.__('This blog is removed').'.</p>'; 
    226 } 
    227  
     293     $_ctx->addMessageStatic(__('This blog is removed')); 
     294} 
     295 
     296# Config errors messages 
    228297if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) { 
    229      echo 
    230      '<p class="static-msg">'. 
    231      sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL'). 
    232      ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 
    233      '</p>'; 
    234 } 
    235  
     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} 
    236303if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) { 
    237      echo 
    238      '<p class="static-msg">'. 
    239      sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM'). 
    240      ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 
    241      '</p>'; 
    242 } 
    243  
    244 $err = array(); 
    245  
    246 # Check cache directory 
    247 if ( $core->auth->isSuperAdmin() ) { 
    248      if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) { 
    249           $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>'; 
    250      } 
    251 } else { 
    252      if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) { 
    253           $err[] = '<p>'.__("The cache directory does not exist or is not writable. You should contact your administrator.").'</p>'; 
    254      } 
    255 } 
    256  
    257 # Check public directory 
    258 if ( $core->auth->isSuperAdmin() ) { 
    259      if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) { 
    260           $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>'; 
    261      } 
    262 } else { 
    263      if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) { 
    264           $err[] = '<p>'.__("There is no writable root directory for the media manager. You should contact your administrator.").'</p>'; 
    265      } 
    266 } 
    267  
    268 # Error list 
    269 if (count($err) > 0) { 
    270      echo '<div class="error"><p><strong>'.__('Error:').'</strong></p>'. 
    271      '<ul><li>'.implode("</li><li>",$err).'</li></ul></div>'; 
    272 } 
    273  
    274 # Plugins install messages 
    275 if (!empty($plugins_install['success'])) 
    276 { 
    277      echo '<div class="success">'.__('Following plugins have been installed:').'<ul>'; 
    278      foreach ($plugins_install['success'] as $k => $v) { 
    279           echo '<li>'.$k.'</li>'; 
    280      } 
    281      echo '</ul></div>'; 
    282 } 
    283 if (!empty($plugins_install['failure'])) 
    284 { 
    285      echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 
    286      foreach ($plugins_install['failure'] as $k => $v) { 
    287           echo '<li>'.$k.' ('.$v.')</li>'; 
    288      } 
    289      echo '</ul></div>'; 
    290 } 
    291 # Errors modules notifications 
    292 if ($core->auth->isSuperAdmin()) 
    293 { 
    294      $list = $core->plugins->getErrors(); 
    295      if (!empty($list)) { 
    296           echo 
    297           '<div class="error" id="module-errors" class="error"><p>'.__('Errors have occured with following plugins:').'</p> '. 
    298           '<ul><li>'.implode("</li>\n<li>", $list).'</li></ul></div>'; 
    299      } 
    300 } 
    301  
    302 # Dashboard columns (processed first, as we need to know the result before displaying the icons.) 
    303 $dashboardItems = ''; 
    304  
    305 foreach ($__dashboard_items as $i) 
    306 { 
    307      if ($i->count() > 0) 
    308      { 
    309           $dashboardItems .= ''; 
    310           foreach ($i as $v) { 
    311                $dashboardItems .= $v; 
    312           } 
    313           $dashboardItems .= ''; 
    314      } 
    315 } 
    316  
    317 # Dashboard elements 
    318 echo '<div id="dashboard-main">'; 
    319  
    320 # Dashboard icons 
    321 echo '<div id="icons">'; 
    322 foreach ($__dashboard_icons as $i) 
    323 { 
    324      echo 
    325      '<p><a href="'.$i[1].'"><img src="'.dc_admin_icon_url($i[2]).'" alt="" />'. 
    326      '<br /><span>'.$i[0].'</span></a></p>'; 
    327 } 
    328 echo '</div>'; 
    329  
    330 if ($core->auth->user_prefs->dashboard->quickentry) { 
    331      if ($core->auth->check('usage,contentadmin',$core->blog->id)) 
    332      { 
    333           # Getting categories 
    334           $categories_combo = dcAdminCombos::getCategoriesCombo( 
    335                $core->blog->getCategories(array('post_type'=>'post')) 
    336           ); 
    337  
    338           echo 
    339           '<div id="quick">'. 
    340           '<h3>'.__('Quick entry').'</h3>'. 
    341           '<form id="quick-entry" action="'.$core->adminurl->get('admin.post').'" method="post" class="fieldset">'. 
    342           '<h4>'.__('New entry').'</h4>'. 
    343           '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 
    344           form::field('post_title',20,255,'','maximal'). 
    345           '</p>'. 
    346           '<p class="area"><label class="required" '. 
    347           'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 
    348           form::textarea('post_content',50,10). 
    349           '</p>'. 
    350           '<p><label for="cat_id" class="classic">'.__('Category:').'</label> '. 
    351           form::combo('cat_id',$categories_combo).'</p>'. 
    352           ($core->auth->check('categories', $core->blog->id) 
    353                ? '<div>'. 
    354                '<p id="new_cat" class="q-cat">'.__('Add a new category').'</p>'. 
    355                '<p class="q-cat"><label for="new_cat_title">'.__('Title:').'</label> '. 
    356                form::field('new_cat_title',30,255,'','').'</p>'. 
    357                '<p class="q-cat"><label for="new_cat_parent">'.__('Parent:').'</label> '. 
    358                form::combo('new_cat_parent',$categories_combo,'',''). 
    359                '</p>'. 
    360                '<p class="form-note info clear">'.__('This category will be created when you will save your post.').'</p>'. 
    361                '</div>' 
    362                : ''). 
    363           '<p><input type="submit" value="'.__('Save').'" name="save" /> '. 
    364           ($core->auth->check('publish',$core->blog->id) 
    365                ? '<input type="hidden" value="'.__('Save and publish').'" name="save-publish" />' 
    366                : ''). 
    367           $core->formNonce(). 
    368           form::hidden('post_status',-2). 
    369           form::hidden('post_format',$core->auth->getOption('post_format')). 
    370           form::hidden('post_excerpt',''). 
    371           form::hidden('post_lang',$core->auth->getInfo('user_lang')). 
    372           form::hidden('post_notes',''). 
    373           '</p>'. 
    374           '</form>'. 
    375           '</div>'; 
    376      } 
    377 } 
    378  
    379 foreach ($__dashboard_contents as $i) 
    380 { 
    381      if ($i->count() > 0) 
    382      { 
    383           $dashboardContents .= ''; 
    384           foreach ($i as $v) { 
    385                $dashboardContents .= $v; 
    386           } 
    387           $dashboardContents .= ''; 
    388      } 
    389 } 
    390  
    391 if ($dashboardContents != '' || $dashboardItems != '') { 
    392      echo 
    393      '<div id="dashboard-boxes">'. 
    394      '<div class="db-items">'.$dashboardItems.$dashboardContents.'</div>'. 
    395      '</div>'; 
    396 } 
    397  
    398 echo '</div>'; #end dashboard-main 
    399 dcPage::helpBlock('core_dashboard'); 
    400 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

    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

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

    r2720 r2911  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1212 
    1313require dirname(__FILE__).'/../inc/admin/prepend.php'; 
    14  
     14global $_ctx; 
    1515dcPage::check('usage,contentadmin'); 
    1616 
     
    4747{ 
    4848     # Filter form we'll put in html_block 
    49      $users_combo = array_merge( 
    50           array('-' => ''), 
    51           dcAdminCombos::getUsersCombo($users) 
     49     $users_combo = $categories_combo = array(); 
     50     while ($users->fetch()) 
     51     { 
     52          $user_cn = dcUtils::getUserCN($users->user_id,$users->user_name, 
     53          $users->user_firstname,$users->user_displayname); 
     54           
     55          if ($user_cn != $users->user_id) { 
     56               $user_cn .= ' ('.$users->user_id.')'; 
     57          } 
     58           
     59          $users_combo[$user_cn] = $users->user_id;  
     60     } 
     61      
     62 
     63# Getting categories 
     64$categories_combo = array(); 
     65try { 
     66     $categories = $core->blog->getCategories(array('post_type'=>'post')); 
     67     while ($categories->fetch()) { 
     68          $categories_combo[$categories->cat_id] =  
     69               str_repeat('&nbsp;&nbsp;',$categories->level-1). 
     70               ($categories->level-1 == 0 ? '' : '&bull; '). 
     71               html::escapeHTML($categories->cat_title); 
     72     } 
     73} catch (Exception $e) { } 
     74     $status_combo = array( 
    5275     ); 
     76     foreach ($core->blog->getAllPostStatus() as $k => $v) { 
     77          $status_combo[(string) $k] = (string)$v; 
     78     } 
     79      
     80     $selected_combo = array( 
     81     '1' => __('is selected'), 
     82     '0' => __('is not selected') 
     83     ); 
     84      
     85     # Months array 
     86     while ($dates->fetch()) { 
     87          $dt_m_combo[$dates->year().$dates->month()] = dt::str('%B %Y',$dates->ts()); 
     88     } 
     89      
     90     while ($langs->fetch()) { 
     91          $lang_combo[$langs->post_lang] = $langs->post_lang; 
     92     } 
     93} 
     94$form = new dcForm($core,'post','post.php'); 
    5395 
    54      $categories_combo = array_merge( 
    55           array( 
    56                new formSelectOption('-',''), 
    57                new formSelectOption(__('(No cat)'),'NULL')), 
    58           dcAdminCombos::getCategoriesCombo($categories,false) 
     96 
     97# Actions combo box 
     98$combo_action = array(); 
     99if ($core->auth->check('publish,contentadmin',$core->blog->id)) 
     100{ 
     101     $combo_action[__('Status')] = array( 
     102          __('Publish') => 'publish', 
     103          __('Unpublish') => 'unpublish', 
     104          __('Schedule') => 'schedule', 
     105          __('Mark as pending') => 'pending' 
    59106     ); 
    60      $categories_values = array(); 
    61      foreach ($categories_combo as $cat) { 
    62           if (isset($cat->value)) { 
    63                $categories_values[$cat->value]=true; 
    64           } 
     107} 
     108$combo_action[__('Mark')] = array( 
     109     __('Mark as selected') => 'selected', 
     110     __('Mark as unselected') => 'unselected' 
     111); 
     112$combo_action[__('Change')] = array( 
     113     __('Change category') => 'category', 
     114     __('Change language') => 'lang'); 
     115if ($core->auth->check('admin',$core->blog->id)) 
     116{ 
     117     $combo_action[__('Change')] = array_merge($combo_action[__('Change')], 
     118          array(__('Change author') => 'author')); 
     119} 
     120if ($core->auth->check('delete,contentadmin',$core->blog->id)) 
     121{ 
     122     $combo_action[__('Delete')] = array(__('Delete') => 'delete'); 
     123} 
     124 
     125# --BEHAVIOR-- adminPostsActionsCombo 
     126$core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); 
     127 
     128 
     129 
     130class monthdcFilterCombo extends dcFilterCombo { 
     131     public function applyFilter($params) { 
     132          $month=$this->avalues['values'][0]; 
     133          $params['post_month'] = substr($month,4,2); 
     134          $params['post_year'] = substr($month,0,4); 
     135     } 
     136} 
     137 
     138class PostsFetcher extends dcListFetcher { 
     139 
     140     public function getEntries($params,$offset,$limit) { 
     141          $params['limit'] = array($offset,$limit); 
     142          return $this->core->blog->getPosts($params); 
    65143     } 
    66144 
    67      $status_combo = array_merge( 
    68           array('-' => ''), 
    69           dcAdminCombos::getPostStatusesCombo() 
    70      ); 
    71  
    72      $selected_combo = array( 
    73      '-' => '', 
    74      __('Selected') => '1', 
    75      __('Not selected') => '0' 
    76      ); 
    77  
    78      $attachment_combo = array( 
    79      '-' => '', 
    80      __('With attachments') => '1', 
    81      __('Without attachments') => '0' 
    82      ); 
    83  
    84      # Months array 
    85      $dt_m_combo = array_merge( 
    86           array('-' => ''), 
    87           dcAdminCombos::getDatesCombo($dates) 
    88      ); 
    89  
    90      $lang_combo = array_merge( 
    91           array('-' => ''), 
    92           dcAdminCombos::getLangsCombo($langs,false) 
    93      ); 
    94  
    95      $sortby_combo = array( 
    96      __('Date') => 'post_dt', 
    97      __('Title') => 'post_title', 
    98      __('Category') => 'cat_title', 
    99      __('Author') => 'user_id', 
    100      __('Status') => 'post_status', 
    101      __('Selected') => 'post_selected', 
    102      __('Number of comments') => 'nb_comment', 
    103      __('Number of trackbacks') => 'nb_trackback' 
    104      ); 
    105  
    106      $order_combo = array( 
    107      __('Descending') => 'desc', 
    108      __('Ascending') => 'asc' 
    109      ); 
    110 } 
    111  
    112 # Actions combo box 
    113  
    114 $posts_actions_page = new dcPostsActionsPage($core,$core->adminurl->get("admin.posts")); 
    115  
    116 if ($posts_actions_page->process()) { 
    117      return; 
    118 } 
    119  
    120 /* Get posts 
    121 -------------------------------------------------------- */ 
    122 $user_id = !empty($_GET['user_id']) ?   $_GET['user_id'] : ''; 
    123 $cat_id = !empty($_GET['cat_id']) ?     $_GET['cat_id'] : ''; 
    124 $status = isset($_GET['status']) ? $_GET['status'] : ''; 
    125 $selected = isset($_GET['selected']) ?  $_GET['selected'] : ''; 
    126 $attachment = isset($_GET['attachment']) ?   $_GET['attachment'] : ''; 
    127 $month = !empty($_GET['month']) ?       $_GET['month'] : ''; 
    128 $lang = !empty($_GET['lang']) ?         $_GET['lang'] : ''; 
    129 $sortby = !empty($_GET['sortby']) ?     $_GET['sortby'] : 'post_dt'; 
    130 $order = !empty($_GET['order']) ?       $_GET['order'] : 'desc'; 
    131  
    132 $show_filters = false; 
    133  
    134 $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; 
    135 $nb_per_page =  30; 
    136  
    137 if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { 
    138      if ($nb_per_page != $_GET['nb']) { 
    139           $show_filters = true; 
     145     public function getEntriesCount($params) { 
     146          $count = $this->core->blog->getPosts($params,true); 
     147          return $count->f(0); 
    140148     } 
    141      $nb_per_page = (integer) $_GET['nb']; 
    142 } 
    143  
    144 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); 
    145 $params['no_content'] = true; 
    146  
    147 # - User filter 
    148 if ($user_id !== '' && in_array($user_id,$users_combo)) { 
    149      $params['user_id'] = $user_id; 
    150      $show_filters = true; 
    151 } else { 
    152      $user_id=''; 
    153 } 
    154  
    155 # - Categories filter 
    156 if ($cat_id !== '' && isset($categories_values[$cat_id])) { 
    157      $params['cat_id'] = $cat_id; 
    158      $show_filters = true; 
    159 } else { 
    160      $cat_id=''; 
    161 } 
    162  
    163 # - Status filter 
    164 if ($status !== '' && in_array($status,$status_combo)) { 
    165      $params['post_status'] = $status; 
    166      $show_filters = true; 
    167 } else { 
    168      $status=''; 
    169 } 
    170  
    171 # - Selected filter 
    172 if ($selected !== '' && in_array($selected,$selected_combo)) { 
    173      $params['post_selected'] = $selected; 
    174      $show_filters = true; 
    175 } else { 
    176      $selected=''; 
    177 } 
    178  
    179 # - Selected filter 
    180 if ($attachment !== '' && in_array($attachment,$attachment_combo)) { 
    181      $params['media'] = $attachment; 
    182      $params['link_type'] = 'attachment'; 
    183      $show_filters = true; 
    184 } else { 
    185      $attachment=''; 
    186 } 
    187  
    188 # - Month filter 
    189 if ($month !== '' && in_array($month,$dt_m_combo)) { 
    190      $params['post_month'] = substr($month,4,2); 
    191      $params['post_year'] = substr($month,0,4); 
    192      $show_filters = true; 
    193 } else { 
    194      $month=''; 
    195 } 
    196  
    197 # - Lang filter 
    198 if ($lang !== '' && in_array($lang,$lang_combo)) { 
    199      $params['post_lang'] = $lang; 
    200      $show_filters = true; 
    201 } else { 
    202      $lang=''; 
    203 } 
    204  
    205 # - Sortby and order filter 
    206 if ($sortby !== '' && in_array($sortby,$sortby_combo)) { 
    207      if ($order !== '' && in_array($order,$order_combo)) { 
    208           $params['order'] = $sortby.' '.$order; 
    209      } else { 
    210           $order='desc'; 
    211      } 
    212  
    213      if ($sortby != 'post_dt' || $order != 'desc') { 
    214           $show_filters = true; 
    215      } 
    216 } else { 
    217      $sortby='post_dt'; 
    218      $order='desc'; 
    219 } 
    220  
    221 # Get posts 
    222 try { 
    223      $posts = $core->blog->getPosts($params); 
    224      $counter = $core->blog->getPosts($params,true); 
    225      $post_list = new adminPostList($core,$posts,$counter->f(0)); 
    226 } catch (Exception $e) { 
    227      $core->error->add($e->getMessage()); 
    228149} 
    229150 
    230151/* DISPLAY 
    231152-------------------------------------------------------- */ 
     153$filterSet = new dcFilterSet($core,'fposts','posts.php'); 
    232154 
    233 $form_filter_title = __('Show filters and display options'); 
    234 $starting_script  = dcPage::jsLoad('js/_posts_list.js'); 
    235 $starting_script .= dcPage::jsLoad('js/filter-controls.js'); 
    236 $starting_script .= 
    237      '<script type="text/javascript">'."\n". 
    238      "//<![CDATA["."\n". 
    239      dcPage::jsVar('dotclear.msg.show_filters', $show_filters ? 'true':'false')."\n". 
    240      dcPage::jsVar('dotclear.msg.filter_posts_list',$form_filter_title)."\n". 
    241      dcPage::jsVar('dotclear.msg.cancel_the_filter',__('Cancel filters and display options'))."\n". 
    242      "//]]>". 
    243      "</script>"; 
     155$filterSet 
     156     ->addFilter(new dcFilterRichCombo( 
     157          'users',__('Author'), __('Author'), 'user_id', $users_combo,array( 
     158               'multiple' => true))) 
     159     ->addFilter(new dcFilterRichCombo( 
     160          'category',__('Category'), __('Category'), 'cat_id', $categories_combo,array( 
     161               'multiple' => true))) 
     162     ->addFilter(new dcFilterRichCombo( 
     163          'post_status',__('Status'), __('Status'), 'post_status', $status_combo)) 
     164     ->addFilter(new dcFilterRichCombo( 
     165          'lang',__('Lang'), __('Lang'), 'post_lang', $lang_combo)) 
     166     ->addFilter(new dcFilterCombo( 
     167          'selected',__('Selected'), __('The post : '),'post_selected', $selected_combo)) 
     168     ->addFilter(new monthdcFilterCombo( 
     169          'month',__('Month'),__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1))) 
     170     ->addFilter(new dcFilterText( 
     171          'search',__('Contains'),__('The entry contains'), 'search',20,255)); 
    244172 
    245 dcPage::open(__('Entries'),$starting_script, 
    246      dcPage::breadcrumb( 
    247           array( 
    248                html::escapeHTML($core->blog->name) => '', 
    249                __('Entries') => '' 
    250           )) 
    251 ); 
    252 if (!empty($_GET['upd'])) { 
    253      dcPage::success(__('Selected entries have been successfully updated.')); 
    254 } elseif (!empty($_GET['del'])) { 
    255      dcPage::success(__('Selected entries have been successfully deleted.')); 
    256 } 
    257 if (!$core->error->flag()) 
    258 { 
    259      echo 
    260      '<p class="top-add"><a class="button add" href="'.$core->adminurl->get("admin.post").'">'.__('New entry').'</a></p>'. 
    261      '<form action="'.$core->adminurl->get("admin.posts").'" method="get" id="filters-form">'. 
    262      '<h3 class="out-of-screen-if-js">'.$form_filter_title.'</h3>'. 
    263173 
    264      '<div class="table">'. 
    265      '<div class="cell">'. 
    266      '<h4>'.__('Filters').'</h4>'. 
    267      '<p><label for="user_id" class="ib">'.__('Author:').'</label> '. 
    268      form::combo('user_id',$users_combo,$user_id).'</p>'. 
    269      '<p><label for="cat_id" class="ib">'.__('Category:').'</label> '. 
    270      form::combo('cat_id',$categories_combo,$cat_id).'</p>'. 
    271      '<p><label for="status" class="ib">'.__('Status:').'</label> ' . 
    272      form::combo('status',$status_combo,$status).'</p> '. 
    273      '</div>'. 
     174$lfetcher = new PostsFetcher($core); 
     175$lposts = new dcItemList ($core,array('lposts','form-entries'),$lfetcher,'posts_actions.php'); 
     176$lposts->setFilterSet($filterSet); 
     177$lposts->addTemplate('posts_cols.html.twig'); 
    274178 
    275      '<div class="cell filters-sibling-cell">'. 
    276      '<p><label for="selected" class="ib">'.__('Selected:').'</label> '. 
    277      form::combo('selected',$selected_combo,$selected).'</p>'. 
    278      '<p><label for="attachment" class="ib">'.__('Attachments:').'</label> '. 
    279      form::combo('attachment',$attachment_combo,$attachment).'</p>'. 
    280      '<p><label for="month" class="ib">'.__('Month:').'</label> '. 
    281      form::combo('month',$dt_m_combo,$month).'</p>'. 
    282      '<p><label for="lang" class="ib">'.__('Lang:').'</label> '. 
    283      form::combo('lang',$lang_combo,$lang).'</p> '. 
    284      '</div>'. 
     179$lposts 
     180     ->addColumn(new dcColumn('title',__('Title'),'post_title')) 
     181     ->addColumn(new dcColumn('cat',__('Category'),'cat_title')) 
     182     ->addColumn(new dcColumn('date',__('Date'),'post_date')) 
     183     ->addColumn(new dcColumn('datetime',__('Date and Time'),'post_dt')) 
     184     ->addColumn(new dcColumn('author',__('Author'),'user_id')) 
     185     ->addColumn(new dcColumn('status',__('Status'),'post_status')); 
    285186 
    286      '<div class="cell filters-options">'. 
    287      '<h4>'.__('Display options').'</h4>'. 
    288      '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. 
    289      form::combo('sortby',$sortby_combo,$sortby).'</p>'. 
    290      '<p><label for="order" class="ib">'.__('Sort:').'</label> '. 
    291      form::combo('order',$order_combo,$order).'</p>'. 
    292      '<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'. 
    293      form::field('nb',3,3,$nb_per_page).' '. 
    294      __('entries per page').'</label></p>'. 
    295      '</div>'. 
    296      '</div>'. 
    297187 
    298      '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. 
    299      '<br class="clear" /></p>'. //Opera sucks 
    300      '</form>'; 
     188$lposts->setup(); 
    301189 
    302      # Show posts 
    303      $post_list->display($page,$nb_per_page, 
    304      '<form action="'.$core->adminurl->get("admin.posts").'" method="post" id="form-entries">'. 
     190$_ctx 
     191     ->setBreadCrumb(array(__('Entries') => 'posts.php')); 
    305192 
    306      '%s'. 
    307193 
    308      '<div class="two-cols">'. 
    309      '<p class="col checkboxes-helpers"></p>'. 
     194$core->tpl->display('posts.html.twig'); 
    310195 
    311      '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '. 
    312      form::combo('action',$posts_actions_page->getCombo()). 
    313      '<input type="submit" value="'.__('ok').'" /></p>'. 
    314      form::hidden(array('user_id'),$user_id). 
    315      form::hidden(array('cat_id'),$cat_id). 
    316      form::hidden(array('status'),$status). 
    317      form::hidden(array('selected'),$selected). 
    318      form::hidden(array('attachment'),$attachment). 
    319      form::hidden(array('month'),$month). 
    320      form::hidden(array('lang'),$lang). 
    321      form::hidden(array('sortby'),$sortby). 
    322      form::hidden(array('order'),$order). 
    323      form::hidden(array('page'),$page). 
    324      form::hidden(array('nb'),$nb_per_page). 
    325      $core->formNonce(). 
    326      '</div>'. 
    327      '</form>', 
    328      $show_filters 
    329      ); 
    330 } 
    331196 
    332 dcPage::helpBlock('core_posts'); 
    333 dcPage::close(); 
     197?> 
  • inc/admin/class.dc.menu.php

    r2566 r2593  
    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 
     
    1414class dcMenu 
    1515{ 
     16     private $items; 
    1617     private $id; 
    1718     public $title; 
    18  
    19      public function __construct($id,$title,$itemSpace='') 
     19     public $separator; 
     20      
     21     public function __construct($id,$title,$separator='') 
    2022     { 
    2123          $this->id = $id; 
    2224          $this->title = $title; 
    23           $this->itemSpace = $itemSpace; 
     25          $this->separator = $separator; 
    2426          $this->items = array(); 
    2527     } 
    26  
     28      
     29     public function getID() 
     30     { 
     31          return $this->id; 
     32     } 
     33      
     34     public function getTitle() 
     35     { 
     36          return $this->title; 
     37     } 
     38      
     39     public function getSeparator() 
     40     { 
     41          return $this->separator; 
     42     } 
     43      
     44     public function getItems() 
     45     { 
     46          return $this->items; 
     47     } 
     48      
    2749     public function addItem($title,$url,$img,$active,$show=true,$id=null,$class=null) 
    2850     { 
     
    3153          } 
    3254     } 
    33  
     55      
    3456     public function prependItem($title,$url,$img,$active,$show=true,$id=null,$class=null) 
    3557     { 
     
    3860          } 
    3961     } 
    40  
    41      public function draw() 
    42      { 
    43           if (count($this->items) == 0) { 
    44                return ''; 
    45           } 
    46  
    47           $res = 
    48           '<div id="'.$this->id.'">'. 
    49           ($this->title ? '<h3>'.$this->title.'</h3>' : ''). 
    50           '<ul>'."\n"; 
    51  
    52           for ($i=0; $i<count($this->items); $i++) 
    53           { 
    54                if ($i+1 < count($this->items) && $this->itemSpace != '') { 
    55                     $res .= preg_replace('|</li>$|',$this->itemSpace.'</li>',$this->items[$i]); 
    56                     $res .= "\n"; 
    57                } else { 
    58                     $res .= $this->items[$i]."\n"; 
    59                } 
    60           } 
    61  
    62           $res .= '</ul></div>'."\n"; 
    63  
    64           return $res; 
    65      } 
    66  
     62      
    6763     protected function itemDef($title,$url,$img,$active,$id=null,$class=null) 
    6864     { 
     
    7470               $ahtml = ''; 
    7571          } 
    76  
    77           $img = dc_admin_icon_url($img); 
    78  
     72           
     73          return array( 
     74               'title' => $title, 
     75               'link' => $link, 
     76               'ahtml' => $ahtml, 
     77               'img' => dc_admin_icon_url($img), 
     78               'active' => (boolean) $active, 
     79               'id' => $id, 
     80               'class' => $class 
     81          ); 
     82     } 
     83      
     84     /** 
     85     @deprecated Use Template engine instead 
     86     */ 
     87     public function draw() 
     88     { 
     89          if (count($this->items) == 0) { 
     90               return ''; 
     91          } 
     92           
     93          $res = 
     94          '<div id="'.$this->id.'">'. 
     95          ($this->title ? '<h3>'.$this->title.'</h3>' : ''). 
     96          '<ul>'."\n"; 
     97           
     98          for ($i=0; $i<count($this->items); $i++) 
     99          { 
     100               if ($i+1 < count($this->items) && $this->separator != '') { 
     101                    $res .= preg_replace('|</li>$|',$this->separator.'</li>',$this->drawItem($this->items[$i])); 
     102                    $res .= "\n"; 
     103               } else { 
     104                    $res .= $this->drawItem($this->items[$i])."\n"; 
     105               } 
     106          } 
     107           
     108          $res .= '</ul></div>'."\n"; 
     109           
     110          return $res; 
     111     } 
     112      
     113     /** 
     114     @deprecated Use Template engine instead 
     115     */ 
     116     protected function drawItem($item) 
     117     { 
    79118          return 
    80           '<li'.(($active || $class) ? ' class="'.(($active) ? 'active ' : '').(($class) ? $class : '').'"' : ''). 
    81           (($id) ? ' id="'.$id.'"' : ''). 
    82           (($img) ? ' style="background-image: url('.$img.');"' : ''). 
     119          '<li'.(($item['active'] || $item['class']) ? ' class="'.(($item['active']) ? 'active ' : '').(($item['class']) ? $item['class'] : '').'"' : ''). 
     120          (($item['id']) ? ' id="'.$item['id'].'"' : ''). 
     121          (($item['img']) ? ' style="background-image: url('.$item['img'].');"' : ''). 
    83122          '>'. 
    84  
    85           '<a href="'.$link.'"'.$ahtml.'>'.$title.'</a></li>'."\n"; 
     123           
     124          '<a href="'.$item['link'].'"'.$item['ahtml'].'>'.$item['title'].'</a></li>'."\n"; 
    86125     } 
    87126} 
     127?> 
  • inc/admin/lib.dc.page.php

    r2909 r2911  
    1919     private static $xframe_loaded = false; 
    2020     private static $N_TYPES = array( 
    21           "success" => "success", 
    22           "warning" => "warning-msg", 
    23           "error" => "error", 
    24           "message" => "message", 
     21          "success" => "success",  
     22          "warning" => "warning-msg",  
     23          "error" => "error",  
     24          "message" => "message",  
    2525          "static" => "static-msg"); 
    2626 
     
    109109 
    110110          self::jsLoadIE7(). 
    111           '  <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 
     111          '    <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 
    112112          if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 
    113113               echo 
    114                '  <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 
     114               '    <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 
    115115          } 
    116116 
     
    118118          $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; 
    119119          if (!$user_ui_hide_std_favicon) { 
    120                echo 
     120               echo  
    121121               '<link rel="icon" type="image/png" href="images/favicon96-login.png" />'. 
    122122               '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />'; 
    123123          } 
     124 
    124125          echo 
    125126          self::jsCommon(). 
     
    217218               $notifications = array(); 
    218219          } 
    219  
     220           
    220221          $n = array_merge($options,array('class' => $class,'ts' => time(), 'text' => $message)); 
    221222          if ($type != "static") { 
     
    339340 
    340341          self::jsLoadIE7(). 
    341           '    <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 
     342          '    <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 
    342343          if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 
    343344               echo 
    344                '    <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 
     345               '    <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 
    345346          } 
    346347 
     
    580581                    "</script>\n"; 
    581582     } 
    582  
     583      
    583584     public static function jsCommon() 
    584585     { 
     
    606607          'jsToolBar = {}, jsToolBar.prototype = { elements : {} };'."\n". 
    607608          self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). 
     609 
    608610          self::jsVar('dotclear.img_plus_src','images/expand.png'). 
    609611          self::jsVar('dotclear.img_plus_alt',__('uncover')). 
     
    725727          self::jsVar('dotclear.msg.module_tags', 
    726728               __('Tags:')). 
    727                "\n//]]>\n". 
     729          "\n//]]>\n". 
    728730          "</script>\n"; 
    729731     } 
     
    787789     public static function jsModal() 
    788790     { 
    789           return 
    790           '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n". 
    791           self::jsLoad('js/jquery/jquery.modal.js'). 
    792           '<script type="text/javascript">'."\n". 
    793           "//<![CDATA[\n". 
    794           self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). 
    795           self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). 
    796           "\n//]]>\n". 
    797           "</script>\n"; 
     791     return 
     792     '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n". 
     793     self::jsLoad('js/jquery/jquery.modal.js'). 
     794     '<script type="text/javascript">'."\n". 
     795     "//<![CDATA[\n". 
     796     self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). 
     797     self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). 
     798     "\n//]]>\n". 
     799     "</script>\n"; 
    798800     } 
    799801 
    800802     public static function jsColorPicker() 
    801803     { 
    802           return 
    803           '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". 
    804           self::jsLoad('js/jquery/jquery.farbtastic.js'). 
    805           self::jsLoad('js/color-picker.js'); 
     804     return 
     805     '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". 
     806     self::jsLoad('js/jquery/jquery.farbtastic.js'). 
     807     self::jsLoad('js/color-picker.js'); 
    806808     } 
    807809 
    808810     public static function jsDatePicker() 
    809811     { 
    810           return 
    811           '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". 
    812           self::jsLoad('js/date-picker.js'). 
    813           '<script type="text/javascript">'."\n". 
    814           "//<![CDATA[\n". 
    815  
    816           "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". 
    817           "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". 
    818           "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". 
    819           "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". 
    820           "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". 
    821           "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". 
    822           "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". 
    823           "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". 
    824           "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". 
    825           "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". 
    826           "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". 
    827           "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". 
    828  
    829           "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". 
    830           "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". 
    831           "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". 
    832           "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". 
    833           "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". 
    834           "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". 
    835           "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". 
    836  
    837           "datePicker.prototype.img_src = 'images/date-picker.png'; ". 
     812     return 
     813     '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". 
     814     self::jsLoad('js/date-picker.js'). 
     815     '<script type="text/javascript">'."\n". 
     816     "//<![CDATA[\n". 
     817 
     818     "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". 
     819     "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". 
     820     "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". 
     821     "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". 
     822     "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". 
     823     "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". 
     824     "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". 
     825     "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". 
     826     "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". 
     827     "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". 
     828     "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". 
     829     "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". 
     830 
     831     "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". 
     832     "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". 
     833     "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". 
     834     "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". 
     835     "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". 
     836     "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". 
     837     "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". 
     838 
     839     "datePicker.prototype.img_src = 'images/date-picker.png'; ". 
    838840          "datePicker.prototype.img_alt = '".html::escapeJS(__('Choose date'))."'; ". 
    839841 
    840           "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". 
    841           "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". 
    842  
    843           "\n//]]>\n". 
    844           "</script>\n"; 
    845      } 
    846  
    847  
     842     "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". 
     843     "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". 
     844 
     845     "\n//]]>\n". 
     846     "</script>\n"; 
     847     } 
     848 
     849      
    848850     public static function jsToolBar() 
    849851     { 
     
    853855     public static function jsUpload($params=array(),$base_url=null) 
    854856     { 
    855           if (!$base_url) { 
    856                $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; 
    857           } 
    858  
    859           $params = array_merge($params,array( 
    860                'sess_id='.session_id(), 
    861                'sess_uid='.$_SESSION['sess_browser_uid'], 
    862                'xd_check='.$GLOBALS['core']->getNonce() 
     857     if (!$base_url) { 
     858          $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; 
     859     } 
     860 
     861     $params = array_merge($params,array( 
     862          'sess_id='.session_id(), 
     863          'sess_uid='.$_SESSION['sess_browser_uid'], 
     864          'xd_check='.$GLOBALS['core']->getNonce() 
    863865          )); 
    864866 
    865           return 
    866           '<script type="text/javascript">'."\n". 
    867           "//<![CDATA[\n". 
    868           "dotclear.jsUpload = {};\n". 
    869           "dotclear.jsUpload.msg = {};\n". 
    870           self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). 
    871           self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). 
    872           self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). 
    873           self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). 
    874           self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). 
    875           self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). 
    876           self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). 
    877           self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). 
    878           self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). 
    879           self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). 
    880           self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). 
    881           self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). 
     867     return 
     868     '<script type="text/javascript">'."\n". 
     869     "//<![CDATA[\n". 
     870     "dotclear.jsUpload = {};\n". 
     871     "dotclear.jsUpload.msg = {};\n". 
     872     self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). 
     873     self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). 
     874     self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). 
     875     self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). 
     876     self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). 
     877     self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). 
     878     self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). 
     879     self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). 
     880     self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). 
     881     self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). 
     882     self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). 
     883     self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). 
    882884          self::jsVar('dotclear.jsUpload.msg.send',__('Send')). 
    883885          self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')). 
    884           self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). 
    885           self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). 
    886           self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). 
    887           self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). 
    888           self::jsVar('dotclear.jsUpload.base_url',$base_url). 
    889           "\n//]]>\n". 
     886     self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). 
     887     self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). 
     888     self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). 
     889     self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). 
     890     self::jsVar('dotclear.jsUpload.base_url',$base_url). 
     891     "\n//]]>\n". 
    890892          "</script>\n". 
    891893 
     
    904906     public static function jsToolMan() 
    905907     { 
    906           return 
    907           '<script type="text/javascript" src="js/tool-man/core.js"></script>'. 
    908           '<script type="text/javascript" src="js/tool-man/events.js"></script>'. 
    909           '<script type="text/javascript" src="js/tool-man/css.js"></script>'. 
    910           '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. 
    911           '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. 
    912           '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. 
    913           '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; 
     908     return 
     909     '<script type="text/javascript" src="js/tool-man/core.js"></script>'. 
     910     '<script type="text/javascript" src="js/tool-man/events.js"></script>'. 
     911     '<script type="text/javascript" src="js/tool-man/css.js"></script>'. 
     912     '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. 
     913     '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. 
     914     '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. 
     915     '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; 
    914916     } 
    915917 
    916918     public static function jsMetaEditor() 
    917919     { 
    918           return 
    919           '<script type="text/javascript" src="js/meta-editor.js"></script>'; 
     920     return 
     921     '<script type="text/javascript" src="js/meta-editor.js"></script>'; 
    920922     } 
    921923 
  • inc/admin/prepend.php

    r2815 r2911  
    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]) { 
     
    7373     # We have session information in constants 
    7474     $_COOKIE[DC_SESSION_NAME] = DC_AUTH_SESS_ID; 
    75  
     75      
    7676     if (!$core->auth->checkSession(DC_AUTH_SESS_UID)) { 
    7777          throw new Exception('Invalid session data.'); 
    7878     } 
    79  
     79      
    8080     # Check nonce from POST requests 
    8181     if (!empty($_POST)) 
     
    8585          } 
    8686     } 
    87  
     87      
    8888     if (empty($_SESSION['sess_blog_id'])) { 
    8989          throw new Exception('Permission denied.'); 
    9090     } 
    91  
     91      
    9292     # Loading locales 
    9393     dc_load_locales(); 
    94  
     94      
    9595     $core->setBlog($_SESSION['sess_blog_id']); 
    9696     if (!$core->blog->id) { 
     
    108108               $p[3] = '/'; 
    109109               call_user_func_array('setcookie',$p); 
    110  
     110                
    111111               http::redirect('auth.php'); 
    112112          } 
     
    116116               ,20); 
    117117     } 
    118  
     118      
    119119     # Check nonce from POST requests 
    120120     if (!empty($_POST)) 
     
    127127          } 
    128128     } 
    129  
     129      
    130130     if (!empty($_REQUEST['switchblog']) 
    131131     && $core->auth->getPermissions($_REQUEST['switchblog']) !== false) 
     
    138138               unset($_SESSION['media_manager_page']); 
    139139          } 
    140  
     140           
    141141          # Removing switchblog from URL 
    142142          $redir = $_SERVER['REQUEST_URI']; 
     
    146146          exit; 
    147147     } 
    148  
     148      
    149149     # Check blog to use and log out if no result 
    150150     if (isset($_SESSION['sess_blog_id'])) 
     
    161161          } 
    162162     } 
    163  
     163      
    164164     # Loading locales 
    165165     dc_load_locales(); 
    166  
     166      
    167167     if (isset($_SESSION['sess_blog_id'])) { 
    168168          $core->setBlog($_SESSION['sess_blog_id']); 
     
    214214     } 
    215215     unset($f); 
    216  
     216      
    217217     if (($hfiles = @scandir($locales_root.$_lang.'/help')) !== false) 
    218218     { 
     
    232232     $core->favs = new dcFavorites($core); 
    233233 
     234 
    234235     # [] : Title, URL, small icon, large icon, permissions, id, class 
    235236     # NB : '*' in permissions means any, null means super admin only 
    236  
     237      
    237238     # Menus creation 
    238239     $_menu = new ArrayObject(); 
     
    253254 
    254255     # Set menu titles 
    255  
     256      
    256257     $_menu['System']->title = __('System settings'); 
    257258     $_menu['Blog']->title = __('Blog'); 
     
    274275     addMenuItem('Blog',__('New entry'),'admin.post','images/menu/edit.png', 
    275276          $core->auth->check('usage,contentadmin',$core->blog->id)); 
    276  
     277      
    277278     addMenuItem('System',__('Update'),'admin.update','images/menu/update.png', 
    278279          $core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)); 
     
    292293} 
    293294 
     295# Add admin default templates path 
     296$core->tpl->getLoader()->addPath(dirname(__FILE__).'/default-templates'); 
     297# Set admin context 
     298$_ctx = new dcAdminContext($core); 
     299$core->tpl->addExtension($_ctx); 
     300 
     301# --BEHAVIOR-- adminPrepend 
     302$core->callBehavior('adminPrepend',$core,$_ctx); 
     303?> 
  • inc/core/class.dc.blog.php

    r2800 r2911  
    877877 
    878878          if (!empty($params['user_id'])) { 
    879                $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."' "; 
     879               $not=""; 
     880               if (!empty($params['user_id_not'])) { 
     881                    $not=" not"; 
     882               } 
     883               $strReq .= "AND U.user_id ".$not.$this->con->in($params['user_id'])." "; 
    880884          } 
    881885 
     
    978982 
    979983          if (!$count_only && !empty($params['limit'])) { 
    980                $strReq .= $this->con->limit($params['limit']); 
    981           } 
     984                    $strReq .= $this->con->limit($params['limit']); 
     985               } 
    982986 
    983987          if (!empty($params['sql_only'])) { 
     
    22182222               'UPDATE '.$this->prefix.'comment '. 
    22192223               'SET comment_status = '.$status.' '; 
    2220           $strReq .= 
     2224               $strReq .= 
    22212225               'WHERE comment_id'.$this->con->in($co_ids). 
    22222226               'AND post_id in (SELECT tp.post_id '. 
     
    22752279          } 
    22762280 
    2277           $strReq = 
     2281               $strReq = 
    22782282               'DELETE FROM '.$this->prefix.'comment '. 
    22792283               'WHERE comment_id'.$this->con->in($co_ids).' '. 
     
    22992303          } 
    23002304 
    2301           $strReq = 
     2305               $strReq = 
    23022306               'DELETE FROM '.$this->prefix.'comment '. 
    23032307               'WHERE comment_status = -2 '. 
  • inc/core/class.dc.core.php

    r2753 r2911  
    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/load_plugin_file.php

    r2804 r2911  
    1414if (@is_dir('/usr/lib/clearbricks')) { 
    1515     define('CLEARBRICKS_PATH','/usr/lib/clearbricks'); 
    16 } elseif (is_dir(dirname(__FILE__).'/libs/clearbricks')) { 
    17      define('CLEARBRICKS_PATH',dirname(__FILE__).'/libs/clearbricks'); 
     16} elseif (is_dir(dirname(__FILE__).'/../vendor/dotclear/clearbricks')) { 
     17     define('CLEARBRICKS_PATH',dirname(__FILE__).'/../vendor/dotclear/clearbricks'); 
    1818} elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) { 
    1919     define('CLEARBRICKS_PATH',$_SERVER['CLEARBRICKS_PATH']); 
  • inc/prepend.php

    r2903 r2911  
    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.8-dev'); 
     168define('DC_VERSION','2.99-dev'); 
    143169define('DC_DIGESTS',dirname(__FILE__).'/digests'); 
    144170define('DC_L10N_ROOT',dirname(__FILE__).'/../locales'); 
  • plugins/aboutConfig/_admin.php

    r2849 r2911  
    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 
     
    1616     dcPage::getPF('aboutConfig/icon.png'), 
    1717     preg_match('/'.preg_quote($core->adminurl->get('admin.plugin.aboutConfig')).'(&.*)?$/',$_SERVER['REQUEST_URI']), 
    18      $core->auth->isSuperAdmin()); 
     18          $core->auth->isSuperAdmin()); 
     19 
     20$core->tpl->getLoader()->addPath(dirname(__FILE__).'/admtpl/','aboutConfig'); 
  • plugins/aboutConfig/index.php

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

Sites map