Dotclear


Ignore:
Timestamp:
02/18/18 18:16:29 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

use strict and no more linter warnings/errors as far as possible, switch from inline js to separate loaded file

Location:
plugins/pages
Files:
2 added
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • plugins/pages/_admin.php

    r3265 r3709  
    1010# 
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    12 if (!defined('DC_CONTEXT_ADMIN')) { return; } 
     12if (!defined('DC_CONTEXT_ADMIN')) {return;} 
    1313 
    14 $core->addBehavior('adminColumnsLists',array('pagesColumnsLists','adminColumnsLists')); 
    15 $core->addBehavior('adminDashboardFavorites',array('pagesDashboard','pagesDashboardFavs')); 
    16 $core->addBehavior('adminUsersActionsHeaders','pages_users_actions_headers'); 
     14$core->addBehavior('adminColumnsLists', array('pagesColumnsLists', 'adminColumnsLists')); 
     15$core->addBehavior('adminDashboardFavorites', array('pagesDashboard', 'pagesDashboardFavs')); 
     16$core->addBehavior('adminUsersActionsHeaders', 'pages_users_actions_headers'); 
    1717 
    1818class pagesColumnsLists 
    1919{ 
    20      public static function adminColumnsLists($core,$cols) 
    21      { 
    22           // Set optional columns in pages lists 
    23           $cols['pages'] = array(__('Pages'), array( 
    24                'date' => array(true,__('Date')), 
    25                'author' => array(true,__('Author')), 
    26                'comments' => array(true,__('Comments')), 
    27                'trackbacks' => array(true,__('Trackbacks')) 
    28           )); 
    29      } 
     20    public static function adminColumnsLists($core, $cols) 
     21    { 
     22        // Set optional columns in pages lists 
     23        $cols['pages'] = array(__('Pages'), array( 
     24            'date'       => array(true, __('Date')), 
     25            'author'     => array(true, __('Author')), 
     26            'comments'   => array(true, __('Comments')), 
     27            'trackbacks' => array(true, __('Trackbacks')) 
     28        )); 
     29    } 
    3030} 
    3131 
    3232class pagesDashboard 
    3333{ 
    34      public static function pagesDashboardFavs($core,$favs) 
    35      { 
    36           $favs->register('pages', array( 
    37                'title' => __('Pages'), 
    38                'url' => $core->adminurl->get('admin.plugin.pages'), 
    39                'small-icon' => dcPage::getPF('pages/icon.png'), 
    40                'large-icon' => dcPage::getPF('pages/icon-big.png'), 
    41                'permissions' => 'contentadmin,pages', 
    42                'dashboard_cb' => array('pagesDashboard','pagesDashboardCB'), 
    43                'active_cb' => array('pagesDashboard','pagesActiveCB') 
    44           )); 
    45           $favs->register('newpage', array( 
    46                'title' => __('New page'), 
    47                'url' => $core->adminurl->get('admin.plugin.pages',array('act' => 'page')), 
    48                'small-icon' => dcPage::getPF('pages/icon-np.png'), 
    49                'large-icon' => dcPage::getPF( 'pages/icon-np-big.png'), 
    50                'permissions' => 'contentadmin,pages', 
    51                'active_cb' => array('pagesDashboard','newPageActiveCB') 
    52           )); 
    53      } 
     34    public static function pagesDashboardFavs($core, $favs) 
     35    { 
     36        $favs->register('pages', array( 
     37            'title'        => __('Pages'), 
     38            'url'          => $core->adminurl->get('admin.plugin.pages'), 
     39            'small-icon'  => dcPage::getPF('pages/icon.png'), 
     40            'large-icon'  => dcPage::getPF('pages/icon-big.png'), 
     41            'permissions' => 'contentadmin,pages', 
     42            'dashboard_cb' => array('pagesDashboard', 'pagesDashboardCB'), 
     43            'active_cb'    => array('pagesDashboard', 'pagesActiveCB') 
     44        )); 
     45        $favs->register('newpage', array( 
     46            'title'      => __('New page'), 
     47            'url'         => $core->adminurl->get('admin.plugin.pages', array('act' => 'page')), 
     48            'small-icon' => dcPage::getPF('pages/icon-np.png'), 
     49            'large-icon'  => dcPage::getPF('pages/icon-np-big.png'), 
     50            'permissions' => 'contentadmin,pages', 
     51            'active_cb'   => array('pagesDashboard', 'newPageActiveCB') 
     52        )); 
     53    } 
    5454 
    55      public static function pagesDashboardCB($core,$v) 
    56      { 
    57           $params = new ArrayObject(); 
    58           $params['post_type'] = 'page'; 
    59           $page_count = $core->blog->getPosts($params,true)->f(0); 
    60           if ($page_count > 0) { 
    61                $str_pages = ($page_count > 1) ? __('%d pages') : __('%d page'); 
    62                $v['title'] = sprintf($str_pages,$page_count); 
    63           } 
    64      } 
     55    public static function pagesDashboardCB($core, $v) 
     56    { 
     57        $params              = new ArrayObject(); 
     58        $params['post_type'] = 'page'; 
     59        $page_count          = $core->blog->getPosts($params, true)->f(0); 
     60        if ($page_count > 0) { 
     61            $str_pages = ($page_count > 1) ? __('%d pages') : __('%d page'); 
     62            $v['title'] = sprintf($str_pages, $page_count); 
     63        } 
     64    } 
    6565 
    66      public static function pagesActiveCB($request,$params) 
    67      { 
    68           return ($request == "plugin.php") && 
    69                isset($params['p']) && $params['p'] == 'pages' 
    70                && !(isset($params['act']) && $params['act']=='page'); 
    71      } 
     66    public static function pagesActiveCB($request, $params) 
     67    { 
     68        return ($request == "plugin.php") && 
     69        isset($params['p']) && $params['p'] == 'pages' 
     70        && !(isset($params['act']) && $params['act'] == 'page'); 
     71    } 
    7272 
    73      public static function newPageActiveCB($request,$params) 
    74      { 
    75           return ($request == "plugin.php") && 
    76                isset($params['p']) && $params['p'] == 'pages' 
    77                && isset($params['act']) && $params['act']=='page'; 
    78      } 
     73    public static function newPageActiveCB($request, $params) 
     74    { 
     75        return ($request == "plugin.php") && 
     76        isset($params['p']) && $params['p'] == 'pages' 
     77        && isset($params['act']) && $params['act'] == 'page'; 
     78    } 
    7979} 
    80  
    8180 
    8281function pages_users_actions_headers() 
    8382{ 
    84      return dcPage::jsLoad('index.php?pf=pages/_users_actions.js'); 
     83    return dcPage::jsLoad('index.php?pf=pages/js/_users_actions.js'); 
    8584} 
    8685 
    8786$_menu['Blog']->addItem(__('Pages'), 
    88      $core->adminurl->get('admin.plugin.pages'), 
    89      dcPage::getPF('pages/icon.png'), 
    90      preg_match('/plugin.php(.*)$/',$_SERVER['REQUEST_URI']) && !empty($_REQUEST['p']) && $_REQUEST['p']=='pages', 
    91      $core->auth->check('contentadmin,pages',$core->blog->id)); 
     87    $core->adminurl->get('admin.plugin.pages'), 
     88    dcPage::getPF('pages/icon.png'), 
     89    preg_match('/plugin.php(.*)$/', $_SERVER['REQUEST_URI']) && !empty($_REQUEST['p']) && $_REQUEST['p'] == 'pages', 
     90    $core->auth->check('contentadmin,pages', $core->blog->id)); 
    9291 
    93 $core->auth->setPermissionType('pages',__('manage pages')); 
     92$core->auth->setPermissionType('pages', __('manage pages')); 
    9493 
    95 require dirname(__FILE__).'/_widgets.php'; 
     94require dirname(__FILE__) . '/_widgets.php'; 
  • plugins/pages/list.php

    r3421 r3709  
    1010# 
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    12 if (!defined('DC_CONTEXT_ADMIN')) { return; } 
     12if (!defined('DC_CONTEXT_ADMIN')) {return;} 
    1313dcPage::check('pages,contentadmin'); 
    1414 
     
    1616-------------------------------------------------------- */ 
    1717$params = array( 
    18      'post_type' => 'page' 
     18    'post_type' => 'page' 
    1919); 
    2020 
    21 $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; 
    22 $nb_per_page =  30; 
     21$page        = !empty($_GET['page']) ? max(1, (integer) $_GET['page']) : 1; 
     22$nb_per_page = 30; 
    2323 
    2424if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { 
    25      $nb_per_page = (integer) $_GET['nb']; 
     25    $nb_per_page = (integer) $_GET['nb']; 
    2626} 
    2727 
    28 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); 
     28$params['limit']      = array((($page - 1) * $nb_per_page), $nb_per_page); 
    2929$params['no_content'] = true; 
    30 $params['order'] = 'post_position ASC, post_title ASC'; 
     30$params['order']      = 'post_position ASC, post_title ASC'; 
    3131 
    3232try { 
    33      $pages = $core->blog->getPosts($params); 
    34      $counter = $core->blog->getPosts($params,true); 
    35      $post_list = new adminPagesList($core,$pages,$counter->f(0)); 
     33    $pages    = $core->blog->getPosts($params); 
     34    $counter   = $core->blog->getPosts($params, true); 
     35    $post_list = new adminPagesList($core, $pages, $counter->f(0)); 
    3636} catch (Exception $e) { 
    37      $core->error->add($e->getMessage()); 
     37    $core->error->add($e->getMessage()); 
    3838} 
    3939 
    4040# Actions combo box 
    4141 
    42 $pages_actions_page = new dcPagesActionsPage($core,'plugin.php',array('p'=>'pages')); 
     42$pages_actions_page = new dcPagesActionsPage($core, 'plugin.php', array('p' => 'pages')); 
    4343 
    4444if (!$pages_actions_page->process()) { 
    4545 
    46  
    4746# --BEHAVIOR-- adminPagesActionsCombo 
    48 $core->callBehavior('adminPagesActionsCombo',array(&$combo_action)); 
     47    $core->callBehavior('adminPagesActionsCombo', array(&$combo_action)); 
    4948 
    5049/* Display 
    5150-------------------------------------------------------- */ 
    52 ?> 
     51    ?> 
    5352<html> 
    5453<head> 
    5554  <title><?php echo __('Pages'); ?></title> 
    5655  <?php 
    57      echo 
    58           dcPage::jsLoad('js/jquery/jquery-ui.custom.js'). 
    59           dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js'). 
    60           dcPage::jsLoad(dcPage::getPF('pages/list.js')). 
    61           '<script type="text/javascript">'."\n". 
    62           dcPage::jsVar('dotclear.msg.confirm_delete_posts',__("Are you sure you want to delete selected pages?")). 
    63           '</script>'; 
     56echo 
     57    dcPage::jsLoad('js/jquery/jquery-ui.custom.js') . 
     58    dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') . 
     59    dcPage::jsLoad(dcPage::getPF('pages/js/list.js')) . 
     60    '<script type="text/javascript">' . "\n" . 
     61    dcPage::jsVar('dotclear.msg.confirm_delete_posts', __("Are you sure you want to delete selected pages?")) . 
     62        '</script>'; 
    6463 
    65   ?> 
     64    ?> 
    6665</head> 
    6766 
     
    6968<?php 
    7069echo dcPage::breadcrumb( 
    71      array( 
    72           html::escapeHTML($core->blog->name) => '', 
    73           __('Pages') => '' 
    74      )).dcPage::notices(); 
     70        array( 
     71            html::escapeHTML($core->blog->name) => '', 
     72            __('Pages')                        => '' 
     73        )) . dcPage::notices(); 
    7574 
    76 if (!empty($_GET['upd'])) { 
    77      dcPage::success(__('Selected pages have been successfully updated.')); 
    78 } elseif (!empty($_GET['del'])) { 
    79      dcPage::success(__('Selected pages have been successfully deleted.')); 
    80 } elseif (!empty($_GET['reo'])) { 
    81      dcPage::success(__('Selected pages have been successfully reordered.')); 
    82 } 
    83 echo 
    84 '<p class="top-add"><a class="button add" href="'.$p_url.'&amp;act=page">'.__('New page').'</a></p>'; 
     75    if (!empty($_GET['upd'])) { 
     76        dcPage::success(__('Selected pages have been successfully updated.')); 
     77    } elseif (!empty($_GET['del'])) { 
     78        dcPage::success(__('Selected pages have been successfully deleted.')); 
     79    } elseif (!empty($_GET['reo'])) { 
     80        dcPage::success(__('Selected pages have been successfully reordered.')); 
     81    } 
     82    echo 
     83    '<p class="top-add"><a class="button add" href="' . $p_url . '&amp;act=page">' . __('New page') . '</a></p>'; 
    8584 
    86 if (!$core->error->flag()) 
    87 { 
    88      # Show pages 
    89      $post_list->display($page,$nb_per_page, 
    90      '<form action="'.$core->adminurl->get('admin.plugin').'" method="post" id="form-entries">'. 
     85    if (!$core->error->flag()) { 
     86        # Show pages 
     87        $post_list->display($page, $nb_per_page, 
     88            '<form action="' . $core->adminurl->get('admin.plugin') . '" method="post" id="form-entries">' . 
    9189 
    92      '%s'. 
     90            '%s' . 
    9391 
    94      '<div class="two-cols">'. 
    95      '<p class="col checkboxes-helpers"></p>'. 
     92            '<div class="two-cols">' . 
     93            '<p class="col checkboxes-helpers"></p>' . 
    9694 
    97      '<p class="col right"><label for="action" class="classic">'.__('Selected pages action:').'</label> '. 
    98      form::combo('action',$pages_actions_page->getCombo()). 
    99      '<input id="do-action" type="submit" value="'.__('ok').'" />'. 
    100      form::hidden(array('post_type'),'page'). 
    101      form::hidden(array('p'),'pages'). 
    102      form::hidden(array('act'),'list'). 
    103      $core->formNonce(). 
    104      '</p></div>'. 
    105      '<p class="clear form-note hidden-if-js">'. 
    106      __('To rearrange pages order, change number at the begining of the line, then click on “Save pages order” button.').'</p>'. 
    107      '<p class="clear form-note hidden-if-no-js">'. 
    108      __('To rearrange pages order, move items by drag and drop, then click on “Save pages order” button.').'</p>'. 
    109      '<p><input type="submit" value="'.__('Save pages order').'" name="reorder" class="clear" /></p>'. 
    110      '</form>'); 
    111 } 
    112 dcPage::helpBlock('pages'); 
    113 ?> 
     95            '<p class="col right"><label for="action" class="classic">' . __('Selected pages action:') . '</label> ' . 
     96            form::combo('action', $pages_actions_page->getCombo()) . 
     97            '<input id="do-action" type="submit" value="' . __('ok') . '" />' . 
     98            form::hidden(array('post_type'), 'page') . 
     99            form::hidden(array('p'), 'pages') . 
     100            form::hidden(array('act'), 'list') . 
     101            $core->formNonce() . 
     102            '</p></div>' . 
     103            '<p class="clear form-note hidden-if-js">' . 
     104            __('To rearrange pages order, change number at the begining of the line, then click on “Save pages order” button.') . '</p>' . 
     105            '<p class="clear form-note hidden-if-no-js">' . 
     106            __('To rearrange pages order, move items by drag and drop, then click on “Save pages order” button.') . '</p>' . 
     107            '<p><input type="submit" value="' . __('Save pages order') . '" name="reorder" class="clear" /></p>' . 
     108            '</form>'); 
     109    } 
     110    dcPage::helpBlock('pages'); 
     111    ?> 
    114112</body> 
    115113</html> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map