Changeset 12764


Ignore:
Timestamp:
Dec 18, 2011, 10:46:24 PM (9 years ago)
Author:
mistic100
Message:

feature:2538 Make a unified messages management
use only $pageinfos and $pageerrors vars and and necessary template to all main pages

Location:
trunk
Files:
1 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/identification.php

    r11989 r12764  
    3232
    3333//-------------------------------------------------------------- identification
    34 $errors = array();
    35 
    3634$redirect_to = '';
    3735if ( !empty($_GET['redirect']) )
     
    4038  if ( is_a_guest() )
    4139  {
    42     array_push($errors, l10n('You are not authorized to access the requested page'));
     40    array_push($page['errors'], l10n('You are not authorized to access the requested page'));
    4341  }
    4442}
     
    4947  {
    5048    array_push(
    51       $errors,
     49      $page['errors'],
    5250      l10n('Cookies are blocked or not supported by your browser. You must enable cookies to connect.')
    5351      );
     
    6967    else
    7068    {
    71       array_push( $errors, l10n('Invalid password!') );
     69      array_push($page['errors'], l10n('Invalid password!') );
    7270    }
    7371  }
     
    9795}
    9896
    99 //-------------------------------------------------------------- errors display
    100 if ( sizeof( $errors ) != 0 )
    101 {
    102   $template->assign('errors', $errors);
    103 }
    104 
    10597// include menubar
    10698$themeconf = $template->get_template_vars('themeconf');
  • trunk/include/common.inc.php

    r12553 r12764  
    6464//
    6565$conf = array();
    66 $page = array();
     66$page = array(
     67  'infos' => array(),
     68  'errors' => array(),
     69  );
    6770$user = array();
    6871$lang = array();
  • trunk/include/page_header.php

    r12008 r12764  
    9999}
    100100
     101
     102// messages
     103foreach (array('errors','infos') as $mode)
     104{
     105  if (isset($_SESSION['page_'.$mode]))
     106  {
     107    $page[$mode] = array_merge($page[$mode], $_SESSION['page_'.$mode]);
     108    unset($_SESSION['page_'.$mode]);
     109  }
     110 
     111  if (count($page[$mode]) != 0)
     112  {
     113    $template->assign($mode, $page[$mode]);
     114  }
     115}
     116
    101117trigger_action('loc_end_page_header');
    102118
  • trunk/include/picture_comment.inc.php

    r11839 r12764  
    5454  include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
    5555
    56   $comment_action = insert_user_comment($comm, @$_POST['key'], $infos );
     56  $comment_action = insert_user_comment($comm, @$_POST['key'], $page['infos']);
    5757
    5858  switch ($comment_action)
    5959  {
    6060    case 'moderate':
    61       array_push( $infos, l10n('An administrator must authorize your comment before it is visible.') );
     61      array_push($page['infos'], l10n('An administrator must authorize your comment before it is visible.') );
    6262    case 'validate':
    63       array_push( $infos, l10n('Your comment has been registered'));
     63      array_push($page['infos'], l10n('Your comment has been registered'));
    6464      break;
    6565    case 'reject':
    6666      set_status_header(403);
    67       array_push($infos, l10n('Your comment has NOT been registered because it did not pass the validation rules') );
     67      array_push($page['errors'], l10n('Your comment has NOT been registered because it did not pass the validation rules') );
    6868      break;
    6969    default:
    7070      trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
    7171  }
    72 
    73   $template->assign(
    74       ($comment_action=='reject') ? 'errors' : 'infos',
    75       $infos
    76     );
    7772
    7873  // allow plugins to notify what's going on
  • trunk/nbm.php

    r10824 r12764  
    3838
    3939
    40 
    4140// +-----------------------------------------------------------------------+
    4241// | Main                                                                  |
    4342// +-----------------------------------------------------------------------+
    44 $page['errors'] = array();
    45 $page['infos'] = array();
    46 
    4743if (isset($_GET['subscribe'])
    4844    and preg_match('/^[A-Za-z0-9]{16}$/', $_GET['subscribe']))
     
    6965$template->set_filenames(array('nbm'=>'nbm.tpl'));
    7066
    71 // +-----------------------------------------------------------------------+
    72 // | errors & infos                                                        |
    73 // +-----------------------------------------------------------------------+
    74 $template->assign(
    75     array(
    76       'errors' => $page['errors'],
    77       'infos' => $page['infos'],
    78     )
    79   );
    80  
     67
    8168// include menubar
    8269$themeconf = $template->get_template_vars('themeconf');
  • trunk/password.php

    r12672 r12764  
    241241// | Process form                                                          |
    242242// +-----------------------------------------------------------------------+
    243 
    244 $page['errors'] = array();
    245 $page['infos'] = array();
    246 
    247243if (isset($_POST['submit']))
    248244{
     
    346342  );
    347343
    348 // +-----------------------------------------------------------------------+
    349 // |                        infos & errors display                         |
    350 // +-----------------------------------------------------------------------+
    351 
    352 $template->assign('errors', $page['errors']);
    353 $template->assign('infos', $page['infos']);
    354344
    355345// include menubar
  • trunk/picture.php

    r11839 r12764  
    190190// +-----------------------------------------------------------------------+
    191191
    192 $infos = array();
    193 
    194192// caching first_rank, last_rank, current_rank in the displayed
    195193// section. This should also help in readability.
     
    339337          {
    340338            case 'moderate':
    341               array_push($infos, l10n('An administrator must authorize your comment before it is visible.'));
     339              array_push($page['infos'], l10n('An administrator must authorize your comment before it is visible.'));
    342340            case 'validate':
    343               array_push($infos, l10n('Your comment has been registered'));
     341              array_push($page['infos'], l10n('Your comment has been registered'));
    344342              break;
    345343            case 'reject':
    346344              set_status_header(403);
    347               array_push($infos, l10n('Your comment has NOT been registered because it did not pass the validation rules'));
     345              array_push($page['errors'], l10n('Your comment has NOT been registered because it did not pass the validation rules'));
    348346              break;
    349347            default:
    350348              trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
    351349          }
    352          
    353           $template->assign(
    354               ($comment_action=='reject') ? 'errors' : 'infos',
    355               $infos
    356             );
    357350           
    358351          unset($_POST['content']);
  • trunk/profile.php

    r12672 r12764  
    6565  }
    6666
    67   save_profile_from_post($userdata, $errors);
     67  save_profile_from_post($userdata, $page['errors']);
    6868
    6969  $title= l10n('Your Gallery Customization');
     
    7676    $userdata );
    7777
    78   // +-----------------------------------------------------------------------+
    79   // |                             errors display                            |
    80   // +-----------------------------------------------------------------------+
    81   if (count($errors) != 0)
    82   {
    83     $template->assign('errors', $errors);
    84   }
    8578 
    8679  // include menubar
  • trunk/register.php

    r12610 r12764  
    3838}
    3939
    40 $errors = array();
    4140if (isset($_POST['submit']))
    4241{
     
    4443  {
    4544                set_status_header(403);
    46     array_push($errors, 'Invalid/expired form key');
     45    array_push($page['errors'], 'Invalid/expired form key');
    4746  }
    4847
    4948  if ($_POST['password'] != $_POST['password_conf'])
    5049  {
    51     array_push($errors, l10n('please enter your password again'));
     50    array_push($page['errors'], l10n('please enter your password again'));
    5251  }
    5352
    54   $errors =
     53  $page['errors'] =
    5554      register_user($_POST['login'],
    5655                    $_POST['password'],
    5756                    $_POST['mail_address'],
    5857                    true,
    59                     $errors);
     58                    $page['errors']);
    6059
    61   if (count($errors) == 0)
     60  if (count($page['errors']) == 0)
    6261  {
    6362    $user_id = get_userid($_POST['login']);
     
    9291  ));
    9392
    94 //-------------------------------------------------------------- errors display
    95 if (count($errors) != 0)
    96 {
    97   $template->assign('errors', $errors);
    98 }
    99 
    10093// include menubar
    10194$themeconf = $template->get_template_vars('themeconf');
  • trunk/search.php

    r10824 r12764  
    3232
    3333//------------------------------------------------------------------ form check
    34 $errors = array();
    3534$search = array();
    3635if (isset($_POST['submit']))
     
    149148  else
    150149  {
    151     array_push($errors, l10n('Empty query. No criteria has been entered.'));
     150    array_push($page['errors'], l10n('Empty query. No criteria has been entered.'));
    152151  }
    153152}
    154153//----------------------------------------------------------------- redirection
    155 if (isset($_POST['submit']) and count($errors) == 0)
     154if (isset($_POST['submit']) and count($page['errors']) == 0)
    156155{
    157156  redirect(
     
    223222display_select_cat_wrapper($query, array(), 'category_options', false);
    224223
    225 //-------------------------------------------------------------- errors display
    226 if (sizeof($errors) != 0)
    227 {
    228   $template->assign('errors', $errors);
    229 }
    230224
    231225// include menubar
  • trunk/themes/Sylvia/theme.css

    r12671 r12764  
    250250        color:#f70;
    251251        border:0;
    252         background-color: transparent;
    253         margin-left:125px;
    254         padding:5px 0px 0pt 10pt;
    255         min-height: 48px;
     252        background:transparent url(icon/infos.png) no-repeat center right;
     253        margin-left:40px;
    256254        text-align:left;
    257255}
     
    259257        color:#f33;
    260258        border:0;
    261         background: transparent url(icon/errors.png) no-repeat scroll right top;
    262         margin-left:125px;
    263         padding:5px 0px 0pt 10pt;
    264         min-height: 48px;
     259        background:transparent url(icon/errors.png) no-repeat center right;
     260        margin-left:40px;
    265261        text-align:left;
    266262        font-weight:bold;
  • trunk/themes/default/template/about.tpl

    r10824 r12764  
    99    <h2>{'About'|@translate}</h2>
    1010  </div>
     11 
     12  {include file='infos_errors.tpl'}
     13 
    1114  <div id="piwigoAbout">
    1215  {$ABOUT_MESSAGE}
  • trunk/themes/default/template/comments.tpl

    r12479 r12764  
    1010        <h2>{'User comments'|@translate}</h2>
    1111</div>
     12
     13{include file='infos_errors.tpl'}
    1214
    1315<form class="filter" action="{$F_ACTION}" method="get">
  • trunk/themes/default/template/identification.tpl

    r12479 r12764  
    1111</div>
    1212
    13   {if isset($errors) }
    14   <div class="errors">
    15     <ul>
    16       {foreach from=$errors item=error}
    17       <li>{$error}</li>
    18       {/foreach}
    19     </ul>
    20   </div>
    21   {/if}
     13{include file='infos_errors.tpl'}
    2214
    2315<form action="{$F_LOGIN_ACTION}" method="post" name="login_form" class="properties">
  • trunk/themes/default/template/index.tpl

    r12677 r12764  
    8080</div>{* <!-- titrePage --> *}
    8181
     82{include file='infos_errors.tpl'}
     83
    8284{if !empty($PLUGIN_INDEX_CONTENT_BEGIN)}{$PLUGIN_INDEX_CONTENT_BEGIN}{/if}
    8385
  • trunk/themes/default/template/nbm.tpl

    r10824 r12764  
    1010        </div>
    1111
    12   {if not empty($errors)}
    13   <div class="errors">
    14     <ul>
    15       {foreach from=$errors item=error}
    16       <li>{$error}</li>
    17       {/foreach}
    18     </ul>
    19   </div>
    20   {/if}
    21 
    22   {if not empty($infos)}
    23   <div class="infos">
    24     <ul>
    25       {foreach from=$infos item=info}
    26       <li>{$info}</li>
    27       {/foreach}
    28     </ul>
    29   </div>
    30   {/if}
     12{include file='infos_errors.tpl'}
    3113
    3214</div>
  • trunk/themes/default/template/notification.tpl

    r11182 r12764  
    1515    <h2>{'Notification'|@translate}</h2>
    1616  </div>
     17 
     18  {include file='infos_errors.tpl'}
    1719
    1820  <div class="notification">
  • trunk/themes/default/template/password.tpl

    r12479 r12764  
    1313  </div>
    1414
    15   {if count($errors)}
    16   <div class="errors">
    17     <ul>
    18       {foreach from=$errors item=error}
    19       <li>{$error}</li>
    20       {/foreach}
    21     </ul>
    22   </div>
    23   {/if}
    24 
    25   {if count($infos)}
    26   <div class="infos">
    27     <ul>
    28       {foreach from=$infos item=info}
    29       <li>{$info}</li>
    30       {/foreach}
    31     </ul>
    32   </div>
    33   {/if}
     15{include file='infos_errors.tpl'}
    3416
    3517{if $action ne 'none'}
  • trunk/themes/default/template/picture.tpl

    r12681 r12764  
    88{/if}
    99
    10 {if isset($errors)}
    11 <div class="errors">
    12         <ul>
    13                 {foreach from=$errors item=error}
    14                 <li>{$error}</li>
    15                 {/foreach}
    16         </ul>
    17 </div>
    18 {/if}
    19 {if isset($infos)}
    20 <div class="infos">
    21         <ul>
    22                 {foreach from=$infos item=info}
    23                 <li>{$info}</li>
    24                 {/foreach}
    25         </ul>
    26 </div>
    27 {/if}
     10{include file='infos_errors.tpl'}
    2811
    2912{if !empty($PLUGIN_PICTURE_BEFORE)}{$PLUGIN_PICTURE_BEFORE}{/if}
  • trunk/themes/default/template/profile.tpl

    r10824 r12764  
    11{if isset($MENUBAR)}{$MENUBAR}{/if}
    22<div id="content" class="content">
    3 
    4 {if isset($errors)}
    5 <div class="errors">
    6   <ul>
    7     {foreach from=$errors item=error}
    8     <li>{$error}</li>
    9     {/foreach}
    10   </ul>
    11 </div>
    12 {/if}
    133
    144<div class="titrePage">
     
    2111</div>
    2212
     13{include file='infos_errors.tpl'}
     14
    2315{$PROFILE_CONTENT}
    2416</div> <!-- content -->
  • trunk/themes/default/template/register.tpl

    r12610 r12764  
    1313</div>
    1414
    15 {if isset($errors)}
    16   <div class="errors">
    17     <ul>
    18       {foreach from=$errors item=error}
    19       <li>{$error}</li>
    20       {/foreach}
    21     </ul>
    22   </div>
    23 {/if}
     15{include file='infos_errors.tpl'}
    2416
    2517<form method="post" action="{$F_ACTION}" class="properties" name="register_form">
  • trunk/themes/default/template/search.tpl

    r12693 r12764  
    3131        </div>
    3232
    33 {if isset($errors) }
    34 <div class="errors">
    35   <ul>
    36     {foreach from=$errors item=error}
    37     <li>{$error}</li>
    38     {/foreach}
    39   </ul>
    40 </div>
    41 {/if}
     33{include file='infos_errors.tpl'}
    4234
    4335<form class="filter" method="post" name="search" action="{$F_SEARCH_ACTION}">
  • trunk/themes/default/template/tags.tpl

    r11431 r12764  
    2020        <h2>{'Tags'|@translate}</h2>
    2121</div>
     22
     23{include file='infos_errors.tpl'}
    2224
    2325{if isset($tags)}
  • trunk/themes/default/theme.css

    r12671 r12764  
    735735        margin: 5px;
    736736        border: 1px solid red;
    737         background: #ffe1e1 url(icon/errors.png) no-repeat top right;
     737        background: #ffe1e1 url(icon/errors.png) no-repeat center right;
    738738        padding: 10px 50px 10px 10px;
    739739}
     
    742742.infos {
    743743        color: #002000;
    744         background: #98fb98 url(icon/infos.png) no-repeat top right;
     744        background: #98fb98 url(icon/infos.png) no-repeat center right;
    745745        margin: 5px;
    746746        padding: 10px 50px 10px 10px;
Note: See TracChangeset for help on using the changeset viewer.