Dotclear

Changeset 1074:57967b687622 for inc


Ignore:
Timestamp:
12/17/12 15:17:30 (13 years ago)
Author:
JcDenis
Branch:
twig
Message:
  • dcPage::open and dcPage::close now use template
Location:
inc/admin
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/default-templates/layout.html.twig

    r1072 r1074  
    1515     {{ js.common }} 
    1616     {% endblock %} 
    17      {% block more_header %}{% endblock %} 
    1817</head> 
    1918 
  • inc/admin/lib.dc.page.php

    r973 r1074  
    4949      
    5050     # Top of admin page 
    51      public static function open($title='', $head='') 
    52      { 
    53           global $core; 
    54            
    55           # List of user's blogs 
    56           if ($core->auth->blog_count == 1 || $core->auth->blog_count > 20) 
    57           { 
    58                $blog_box = 
    59                __('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'. 
    60                html::escapeHTML($core->blog->name).'</strong>'; 
    61                 
    62                if ($core->auth->blog_count > 20) { 
    63                     $blog_box .= ' - <a href="blogs.php">'.__('Change blog').'</a>'; 
    64                } 
    65           } 
    66           else 
    67           { 
    68                $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); 
    69                $blogs = array(); 
    70                while ($rs_blogs->fetch()) { 
    71                     $blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id; 
    72                } 
    73                $blog_box = 
    74                '<label for="switchblog" class="classic">'. 
    75                __('Blogs:').' '. 
    76                $core->formNonce(). 
    77                form::combo('switchblog',$blogs,$core->blog->id). 
    78                '</label>'. 
    79                '<noscript><div><input type="submit" value="'.__('ok').'" /></div></noscript>'; 
    80           } 
    81            
    82           $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode']; 
    83            
    84           # Display 
    85           header('Content-Type: text/html; charset=UTF-8'); 
    86           echo 
    87           '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. 
    88           ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". 
    89           '<html xmlns="http://www.w3.org/1999/xhtml" '. 
    90           'xml:lang="'.$core->auth->getInfo('user_lang').'" '. 
    91           'lang="'.$core->auth->getInfo('user_lang').'">'."\n". 
    92           "<head>\n". 
    93           '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". 
    94           '  <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". 
    95            
    96           '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 
    97           '  <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". 
    98            
    99           self::jsLoadIE7(). 
    100           '    <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n";  
    101           if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 
    102                echo 
    103           '    <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n";  
    104           } 
    105  
    106           $core->auth->user_prefs->addWorkspace('interface'); 
    107           $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; 
    108           if (!$user_ui_hide_std_favicon) { 
    109                echo '<link rel="icon" type="image/png" href="images/favicon.png" />'; 
    110           } 
    111            
    112           echo 
    113           self::jsCommon(). 
    114           $head; 
    115            
    116           # --BEHAVIOR-- adminPageHTMLHead 
    117           $core->callBehavior('adminPageHTMLHead'); 
    118            
    119           echo 
    120           "</head>\n". 
    121           '<body id="dotclear-admin'. 
    122           ($safe_mode ? ' safe-mode' : ''). 
    123           '">'."\n". 
    124            
    125           '<div id="header">'. 
    126           '<ul id="prelude"><li><a href="#content">'.__('Go to the content').'</a></li><li><a href="#main-menu">'.__('Go to the menu').'</a></li></ul>'."\n". 
    127           '<div id="top"><h1><a href="index.php">'.DC_VENDOR_NAME.'</a></h1></div>'."\n";  
    128            
    129           echo 
    130           '<div id="info-boxes">'. 
    131           '<div id="info-box1">'. 
    132           '<form action="index.php" method="post">'. 
    133           $blog_box. 
    134           '<a href="'.$core->blog->url.'" onclick="window.open(this.href);return false;" title="'.__('Go to site').' ('.__('new window').')'.'">'.__('Go to site').' <img src="images/outgoing.png" alt="" /></a>'. 
    135           '</form>'. 
    136           '</div>'. 
    137           '<div id="info-box2">'. 
    138           '<a'.(preg_match('/index.php$/',$_SERVER['REQUEST_URI']) ? ' class="active"' : '').' href="index.php">'.__('My dashboard').'</a>'. 
    139           '<span> | </span><a'.(preg_match('/preferences.php(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' class="active"' : '').' href="preferences.php">'.__('My preferences').'</a>'. 
    140           '<span> | </span><a href="index.php?logout=1" class="logout">'.sprintf(__('Logout %s'),$core->auth->userID()).' <img src="images/logout.png" alt="" /></a>'. 
    141           '</div>'. 
    142           '</div>'. 
    143           '</div>'; 
    144            
    145           echo 
    146           '<div id="wrapper">'."\n". 
    147           '<div id="main">'."\n". 
    148           '<div id="content">'."\n"; 
    149            
    150           # Safe mode 
    151           if ($safe_mode) 
    152           { 
    153                echo 
    154                '<div class="error"><h3>'.__('Safe mode').'</h3>'. 
    155                '<p>'.__('You are in safe mode. All plugins have been temporarily disabled. Remind to log out then log in again normally to get back all functionalities').'</p>'. 
    156                '</div>'; 
    157           } 
     51     public static function open($title='',$head='',$popup=false) 
     52     { 
     53          global $core, $_ctx; 
     54           
     55          $_ctx->popup = (boolean) $popup; 
     56          $_ctx->page_header = $head; 
     57          $_ctx->setPageTitle($title); 
     58           
     59          ob_start(); 
     60     } 
     61      
     62     public static function close() 
     63     { 
     64          $res = ob_get_contents(); 
     65          ob_end_clean(); 
     66           
     67          global $core, $_ctx; 
    15868           
    15969          if ($core->error->flag()) { 
    160                echo 
    161                '<div class="error"><p><strong>'.(count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')).'</p></strong>'. 
    162                $core->error->toHTML(). 
    163                '</div>'; 
    164           } 
    165      } 
    166       
    167      public static function close() 
    168      { 
    169           global $core; 
    170  
    171           $menu =& $GLOBALS['_menu']; 
    172            
    173           echo 
    174           "</div>\n".         // End of #content 
    175           "</div>\n".         // End of #main 
    176            
    177           '<div id="main-menu">'."\n"; 
    178            
    179           foreach ($menu as $k => $v) { 
    180                echo $menu[$k]->draw(); 
    181           } 
    182            
    183           $text = sprintf(__('Thank you for using %s.'),'<a href="http://dotclear.org/">Dotclear '.DC_VERSION.'</a>'); 
    184  
    185           # --BEHAVIOR-- adminPageFooter 
    186           $textAlt = $core->callBehavior('adminPageFooter',$core,$text); 
    187  
    188           echo 
    189           '</div>'."\n".      // End of #main-menu 
    190           '<div id="footer"><p>'.($textAlt != '' ? $textAlt : $text).'</p></div>'."\n". 
    191           "</div>\n";         // End of #wrapper 
    192            
    193           if (defined('DC_DEV') && DC_DEV === true) { 
    194                echo self::debugInfo(); 
    195           } 
    196            
    197           echo 
    198           '</body></html>'; 
    199      } 
    200       
    201      public static function openPopup($title='', $head='') 
    202      { 
    203           global $core; 
    204            
    205           # Display 
    206           header('Content-Type: text/html; charset=UTF-8'); 
    207           echo 
    208           '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. 
    209           ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". 
    210           '<html xmlns="http://www.w3.org/1999/xhtml" '. 
    211           'xml:lang="'.$core->auth->getInfo('user_lang').'" '. 
    212           'lang="'.$core->auth->getInfo('user_lang').'">'."\n". 
    213           "<head>\n". 
    214           '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". 
    215           '  <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". 
    216            
    217           '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 
    218           '  <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". 
    219            
    220           self::jsLoadIE7(). 
    221           '    <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n";  
    222           if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 
    223                echo 
    224                '    <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n";  
    225           } 
    226            
    227           echo 
    228           self::jsCommon(). 
    229           $head; 
    230            
    231           # --BEHAVIOR-- adminPageHTMLHead 
    232           $core->callBehavior('adminPageHTMLHead'); 
    233            
    234           echo 
    235           "</head>\n". 
    236           '<body id="dotclear-admin" class="popup">'."\n". 
    237            
    238           '<div id="top"><h1>'.DC_VENDOR_NAME.'</h1></div>'."\n"; 
    239            
    240           echo 
    241           '<div id="wrapper">'."\n". 
    242           '<div id="main">'."\n". 
    243           '<div id="content">'."\n"; 
    244            
    245           if ($core->error->flag()) { 
    246                echo 
    247                '<div class="error"><strong>'.__('Errors:').'</strong>'. 
    248                $core->error->toHTML(). 
    249                '</div>'; 
    250           } 
     70               foreach($core->error->getErrors() as $e) { 
     71                    $_ctx->addError($e); 
     72               } 
     73          } 
     74          $_ctx->page_content = $res; 
     75          $core->tpl->display('page_layout.html.twig'); 
     76     } 
     77      
     78     public static function openPopup($title='',$head='') 
     79     { 
     80          self::open($title,$head,true); 
    25181     } 
    25282      
    25383     public static function closePopup() 
    25484     { 
    255           echo 
    256           "</div>\n".         // End of #content 
    257           "</div>\n".         // End of #main 
    258           '<div id="footer"><p>&nbsp;</p></div>'."\n". 
    259           "</div>\n".         // End of #wrapper 
    260           '</body></html>'; 
     85          self::close(); 
    26186     } 
    26287 
     
    27499               } 
    275100          } 
    276           return $res; 
    277      } 
    278       
    279      private static function debugInfo() 
    280      { 
    281           $global_vars = implode(', ',array_keys($GLOBALS)); 
    282            
    283           $res = 
    284           '<div id="debug"><div>'. 
    285           '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; 
    286            
    287           if (function_exists('xdebug_get_profiler_filename')) 
    288           { 
    289                $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; 
    290                 
    291                $prof_file = xdebug_get_profiler_filename(); 
    292                if ($prof_file) { 
    293                     $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; 
    294                } else { 
    295                     $prof_url = http::getSelfURI(); 
    296                     $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; 
    297                     $prof_url .= 'XDEBUG_PROFILE'; 
    298                     $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>'; 
    299                } 
    300                 
    301                /* xdebug configuration: 
    302                zend_extension = /.../xdebug.so 
    303                xdebug.auto_trace = On 
    304                xdebug.trace_format = 0 
    305                xdebug.trace_options = 1 
    306                xdebug.show_mem_delta = On 
    307                xdebug.profiler_enable = 0 
    308                xdebug.profiler_enable_trigger = 1 
    309                xdebug.profiler_output_dir = /tmp 
    310                xdebug.profiler_append = 0 
    311                xdebug.profiler_output_name = timestamp 
    312                */ 
    313           } 
    314            
    315           $res .= 
    316           '<p>Global vars: '.$global_vars.'</p>'. 
    317           '</div></div>'; 
    318            
    319101          return $res; 
    320102     } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map