Dotclear

Changeset 1089:049be1a46863


Ignore:
Timestamp:
12/19/12 11:57:54 (13 years ago)
Author:
JcDenis
Branch:
twig
Message:
  • Better way to fill in complex page title
  • Group all types of messages
  • Fix aboutConfig form submit
  • Clean up uggly tabs on inline doc
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • admin/auth.php

    r1061 r1089  
    3131     try { 
    3232          if (($changes = dotclearUpgrade($core)) !== false) { 
    33                $_ctx->setMessage(__('Dotclear has been upgraded.').'<!-- '.$changes.' -->'); 
     33               $_ctx->setAlert(__('Dotclear has been upgraded.').'<!-- '.$changes.' -->'); 
    3434          } 
    3535     } 
     
    6464                
    6565               mail::sendMail($recover_res['user_email'],$subject,$message,$headers); 
    66                $_ctx->setMessage(__('Your new password is in your mailbox.')); 
     66               $_ctx->setAlert(__('Your new password is in your mailbox.')); 
    6767          } 
    6868          catch (Exception $e) { 
     
    171171                
    172172               mail::sendMail($user_email,$subject,$message,$headers); 
    173                $_ctx->setMessage(sprintf(__('The e-mail was sent successfully to %s.'),$user_email)); 
     173               $_ctx->setAlert(sprintf(__('The e-mail was sent successfully to %s.'),$user_email)); 
    174174          } 
    175175          catch (Exception $e) { 
  • admin/index.php

    r1080 r1089  
    306306} 
    307307 
    308 $_ctx->setPageTitle(__('Dashboard')); 
     308$_ctx->fillPageTitle(__('Dashboard')); 
    309309$core->tpl->display('index.html.twig'); 
    310310?> 
  • admin/plugin.php

    r1088 r1089  
    9090# No plugin or content found 
    9191if (!$has_content) { 
    92      $_ctx->setPageTitle(__('Plugin not found')); 
     92     $_ctx->fillPageTitle(__('Plugin not found')); 
    9393     $_ctx->addError(__('The plugin you reached does not exist or does not have an admin page.')); 
    9494     $core->tpl->display('plugin.html.twig'); 
  • admin/post.php

    r1088 r1089  
    1717function savePost($form) { 
    1818     global $_ctx; 
    19      $_ctx->setMessage('save'); 
     19     $_ctx->setAlert('save'); 
    2020 
    2121} 
     
    180180     $default_tab = 'comments'; 
    181181} 
    182 $_ctx->default_tab = $default_tab; 
    183 $_ctx->setPageTitle($page_title); 
     182 
     183$_ctx 
     184     ->fillPageTitle(__('Entries'),'posts.php') 
     185     ->fillPageTitle($page_title) 
     186     ->default_tab = $default_tab; 
    184187 
    185188$core->tpl->display('post.html.twig'); 
  • inc/admin/class.dc.admincontext.php

    r1088 r1089  
    3333          # Globals not editable via context 
    3434          $this->protected_globals = array( 
    35                'page_messages_static'   => array(), 
    36                'page_messages_lists'    => array(), 
    37                'page_message' => '', 
    38                'page_errors'  => array(), 
    39                'page_title'   => '', 
     35               'messages' => array( 
     36                    'static' => array(), 
     37                    'lists' => array(), 
     38                    'alert' => '', 
     39                    'errors' => array() 
     40               ), 
     41                
     42               'page_title'   => array(), 
     43               'page_global'  => false, 
    4044                
    4145               'admin_url'    => DC_ADMIN_URL, 
     
    7377     Add a global variable 
    7478      
    75     @param string $name Name of the variable 
    76     @param mixed $value Value of the variable 
     79     @param string $name Name of the variable 
     80     @param mixed $value Value of the variable 
    7781     */ 
    7882     public function __set($name,$value) 
     
    9498      
    9599     @param string $name Name of the variable 
    96     @return mixed Value of the variable or null 
     100     @return mixed Value of the variable or null 
    97101     */ 
    98102     public function __get($name) 
     
    101105     } 
    102106      
    103     /** 
    104     Returns a list of filters to add to the existing list. 
    105      
     107     /** 
     108     Returns a list of filters to add to the existing list. 
     109      
    106110     @return array An array of filters 
    107     */ 
     111     */ 
    108112     public function getFilters() 
    109113     { 
     
    113117     } 
    114118      
    115     /** 
    116     Returns a list of functions to add to the existing list. 
    117      
    118     @return array An array of functions 
    119     */ 
     119     /** 
     120     Returns a list of functions to add to the existing list. 
     121      
     122     @return array An array of functions 
     123     */ 
    120124     public function getFunctions() 
    121125     { 
     
    127131     } 
    128132      
    129     /** 
    130     Returns a list of global variables to add to the existing list. 
     133     /** 
     134     Returns a list of global variables to add to the existing list. 
    131135      
    132136     This merges overloaded variables with defined variables. 
    133      
    134     @return array An array of global variables 
    135     */ 
     137      
     138     @return array An array of global variables 
     139     */ 
    136140     public function getGlobals() 
    137141     { 
     
    157161     } 
    158162      
    159     /** 
    160      * Returns the name of the extension. 
    161      * 
    162      * @return string The extension name 
    163      */ 
     163     /** 
     164     Returns the name of the extension. 
     165      
     166     @return string The extension name 
     167     */ 
    164168     public function getName() 
    165169     { 
     
    188192     public function addMessageStatic($message) 
    189193     { 
    190           $this->protected_globals['page_messages_static'][] = $message; 
     194          $this->protected_globals['messages']['static'][] = $message; 
    191195          return $this; 
    192196     } 
     
    201205     public function addMessagesList($title,$messages) 
    202206     { 
    203           $this->protected_globals['page_messages_lists'][$title] = $messages; 
     207          $this->protected_globals['messages']['lists'][$title] = $messages; 
    204208          return $this; 
    205209     } 
     
    211215     @return object self 
    212216     */ 
    213      public function setMessage($message) 
    214      { 
    215           $this->protected_globals['page_message'] = $message; 
    216           return $this; 
    217      } 
    218  
     217     public function setAlert($message) 
     218     { 
     219          $this->protected_globals['messages']['alert'] = $message; 
     220          return $this; 
     221     } 
     222      
    219223     /** 
    220224     Add an error message 
     
    225229     public function addError($error) 
    226230     { 
    227           $this->protected_globals['page_errors'][] = $error; 
     231          $this->protected_globals['messages']['errors'][] = $error; 
    228232          return $this; 
    229233     } 
     
    236240     public function hasError() 
    237241     { 
    238           return !empty($this->protected_globals['page_errors']); 
    239      } 
    240       
    241      /** 
    242      Add page title 
    243      */ 
    244      public function setPageTitle($title) 
    245      { 
    246           $this->protected_globals['page_title'] = $title; 
     242          return !empty($this->protected_globals['messages']['errors']); 
     243     } 
     244      
     245     /** 
     246     Fill the page title 
     247      
     248     $title can be:  
     249     a string for page title part or  
     250     TRUE to add blog name at the begining of title or 
     251     NULL to empty/reset title 
     252      
     253     @param mixed $title A title part 
     254     @param boolean $url Link of the title part 
     255     @return object self 
     256     */ 
     257     public function fillPageTitle($title,$url='') 
     258     { 
     259          if (is_bool($title)) { 
     260               $this->protected_globals['page_global'] = $title; 
     261          } 
     262          elseif (null === $title) { 
     263               $this->protected_globals['page_global'] = false; 
     264               $this->protected_globals['page_title'] = array(); 
     265          } 
     266          else { 
     267               $this->protected_globals['page_title'][] = array( 
     268                    'title' => $title, 
     269                    'link' => $url 
     270               ); 
     271          } 
     272          return $this; 
    247273     } 
    248274      
     
    256282      
    257283     /** 
    258       * Get list of blogs 
    259       */ 
     284     Get list of blogs 
     285     */ 
    260286     protected function getBlogs() 
    261287     { 
     
    293319      
    294320     /** 
    295       * Get current blog information 
    296       */ 
     321     Get current blog information 
     322     */ 
    297323     protected function getCurrentBlog() 
    298324     { 
     
    318344      
    319345     /** 
    320       * Get current user information 
    321       */ 
     346     Get current user information 
     347     */ 
    322348     protected function getCurrentUser() 
    323349     { 
     
    366392     } 
    367393      
     394     /** 
     395     Get sidebar menus 
     396     */ 
    368397     protected function getMenus() 
    369398     { 
  • inc/admin/default-templates/auth.html.twig

    r1059 r1089  
    2121<div id="login-screen"> 
    2222<h1>{{vendor_name}}</h1> 
    23 {% if page_message is not empty %} 
    24      <p class="message">{{page_message}}</p> 
     23{% if messages.alert is not empty %} 
     24     <p class="message">{{ messages.alert }}</p> 
    2525{% endif %} 
    26 {% if page_errors is not empty %} 
     26{% if messages.errors is not empty %} 
    2727     <div class="error"> 
    2828          <p><strong>Errors :</strong></p> 
    2929          <ul> 
    30           {% for error in page_errors %} 
    31                <li>{{error}}</li> 
     30          {% for error in messages.errors %} 
     31               <li>{{ error }}</li> 
    3232          {% endfor %} 
    3333          </ul> 
  • inc/admin/default-templates/layout.html.twig

    r1087 r1089  
    55     {% block header %} 
    66     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    7      <title>{% block title %}{{page_title}} - {% if current_blog.name is not empty %}{{current_blog.name}} - {% endif %}{{vendor_name}} - {{version}}{% endblock %}</title> 
     7     <title>{% block title %}{% for part in page_title %}{{ part.title }} - {% endfor %}{% if current_blog.name is not empty %}{{current_blog.name}} - {% endif %}{{vendor_name}} - {{version}}{% endblock %}</title> 
    88     <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" /> 
    99     <meta name="GOOGLEBOT" content="NOSNIPPET" /> 
     
    5353                         </div> 
    5454                    {% endif %} 
    55                     <h2>{{current_blog.name}} &rsaquo; <span class="page-title">{{page_title}}</span></h2> 
    56                     {% if page_messages_static is not empty %} 
    57                          {% for message in page_messages_static %} 
     55                    <h2> 
     56                         {%- if not page_global %}{{current_blog.name}} &rsaquo; {% endif %} 
     57                         {%- for part in page_title %} 
     58                              {%- if loop.last %}<span class="page-title">{% endif %} 
     59                              {%- if part.link is not empty %}<a href="{{ part.link }}">{{ part.title }}</a>{% else %}{{ part.title }}{% endif %} 
     60                              {%- if loop.last %}</span>{% else %} &rsaquo; {% endif %} 
     61                         {%- endfor -%} 
     62                    </h2> 
     63                    {% if messages.static is not empty %} 
     64                         {% for message in messages.static %} 
    5865                              <p class="static-msg">{{ message }}</p> 
    5966                         {% endfor %} 
    6067                    {% endif %} 
    61                     {% if page_messages_lists is not empty %} 
    62                          {% for title,messages in page_messages_lists %} 
     68                    {% if messages.lists is not empty %} 
     69                         {% for title,messages in messages.lists %} 
    6370                              <div class="static-msg">{{ title }}<ul> 
    6471                              {% for message in messages %} 
     
    6875                         {% endfor %} 
    6976                    {% endif %} 
    70                     {% if page_message is not empty %} 
    71                          <p class="message">{{page_message}}</p> 
     77                    {% if messages.alert is not empty %} 
     78                         <p class="message">{{ messages.alert }}</p> 
    7279                    {% endif %} 
    73                     {% if page_errors is not empty %} 
     80                    {% if messages.errors is not empty %} 
    7481                         <div class="error"> 
    7582                              <p><strong>Errors :</strong></p> 
    7683                              <ul> 
    77                               {% for error in page_errors %} 
    78                                    <li>{{error}}</li> 
     84                              {% for error in messages.errors %} 
     85                                   <li>{{ error }}</li> 
    7986                              {% endfor %} 
    8087                              </ul> 
  • inc/admin/default-templates/popup.html.twig

    r1074 r1089  
    2424                    {% block content %} 
    2525                    <h2>{{current_blog.name}} &rsaquo; <span class="page-title">{{page_title}}</span></h2> 
    26                     {% if page_message is not empty %} 
    27                          <p class="message">{{page_message}}</p> 
     26                    {% if messages.alert is not empty %} 
     27                         <p class="message">{{ messages.alert }}</p> 
    2828                    {% endif %} 
    29                     {% if page_errors is not empty %} 
     29                    {% if messages.errors is not empty %} 
    3030                         <div class="error"> 
    3131                              <p><strong>Errors :</strong></p> 
    3232                              <ul> 
    33                               {% for error in page_errors %} 
    34                                    <li>{{error}}</li> 
     33                              {% for error in messages.errors %} 
     34                                   <li>{{ error }}</li> 
    3535                              {% endfor %} 
    3636                              </ul> 
  • inc/admin/lib.dc.page.php

    r1085 r1089  
    5555          $_ctx->popup = (boolean) $popup; 
    5656          $_ctx->page_header = $head; 
    57           $_ctx->setPageTitle($title); 
     57          $_ctx->fillPageTitle($title); 
    5858           
    5959          ob_start(); 
  • plugins/aboutConfig/admtpl/index.html.twig

    r1070 r1089  
    4242     </tbody></table> 
    4343    {% endfor %} 
    44      <p>{{ form_field('local_submit') }} </p> 
     44     <p>{{ form_field('local_submit') }}</p> 
    4545    {% endform %} 
    4646     </div> 
     
    7575     </tbody></table> 
    7676    {% endfor %} 
    77      <p>{{ form_field('global_submit') }} </p> 
     77     <p>{{ form_field('global_submit') }}</p> 
    7878    {% endform %} 
    7979  </div> 
  • plugins/aboutConfig/index.php

    r1070 r1089  
    137137# Commons 
    138138if (!empty($_GET['upd'])) { 
    139      $_ctx->setMessage(__('Configuration successfully updated')); 
     139     $_ctx->setAlert(__('Configuration successfully updated')); 
    140140} 
    141141if (!empty($_GET['upda'])) { 
    142      $_ctx->setMessage(__('Settings definition successfully updated')); 
     142     $_ctx->setAlert(__('Settings definition successfully updated')); 
    143143} 
    144144$_ctx->default_tab = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local'; 
    145 $_ctx->setPageTitle('about:config'); 
     145$_ctx->fillPageTitle('about:config'); 
    146146$core->tpl->display('@aboutConfig/index.html.twig'); 
    147147?> 
  • plugins/aboutConfig/js/aboutConfig.js

    r1070 r1089  
    11$(function() { 
    2      $("#global_submit").hide(); 
    3      $("#local_submit").hide(); 
     2     $("#global_nav_submit").hide(); 
     3     $("#local_nav_submit").hide(); 
    44     $("#global_nav").change(function() { 
    55          window.location = $("#global_nav option:selected").val(); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map