Changeset 3709:c88e69474c34 for plugins/pages
- Timestamp:
- 02/18/18 18:16:29 (7 years ago)
- Branch:
- default
- Location:
- plugins/pages
- Files:
-
- 2 added
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/pages/_admin.php
r3265 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 13 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'); 17 17 18 18 class pagesColumnsLists 19 19 { 20 public static function adminColumnsLists($core,$cols)21 22 23 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 } 30 30 } 31 31 32 32 class pagesDashboard 33 33 { 34 public static function pagesDashboardFavs($core,$favs)35 36 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 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 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 } 54 54 55 public static function pagesDashboardCB($core,$v)56 57 $params= new ArrayObject();58 59 $page_count = $core->blog->getPosts($params,true)->f(0);60 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 } 65 65 66 public static function pagesActiveCB($request,$params)67 68 69 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 } 72 72 73 public static function newPageActiveCB($request,$params)74 75 76 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 } 79 79 } 80 81 80 82 81 function pages_users_actions_headers() 83 82 { 84 return dcPage::jsLoad('index.php?pf=pages/_users_actions.js');83 return dcPage::jsLoad('index.php?pf=pages/js/_users_actions.js'); 85 84 } 86 85 87 86 $_menu['Blog']->addItem(__('Pages'), 88 89 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)); 92 91 93 $core->auth->setPermissionType('pages', __('manage pages'));92 $core->auth->setPermissionType('pages', __('manage pages')); 94 93 95 require dirname(__FILE__) .'/_widgets.php';94 require dirname(__FILE__) . '/_widgets.php'; -
plugins/pages/list.php
r3421 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 13 dcPage::check('pages,contentadmin'); 14 14 … … 16 16 -------------------------------------------------------- */ 17 17 $params = array( 18 18 'post_type' => 'page' 19 19 ); 20 20 21 $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1;22 $nb_per_page = 21 $page = !empty($_GET['page']) ? max(1, (integer) $_GET['page']) : 1; 22 $nb_per_page = 30; 23 23 24 24 if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { 25 25 $nb_per_page = (integer) $_GET['nb']; 26 26 } 27 27 28 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);28 $params['limit'] = array((($page - 1) * $nb_per_page), $nb_per_page); 29 29 $params['no_content'] = true; 30 $params['order'] = 'post_position ASC, post_title ASC';30 $params['order'] = 'post_position ASC, post_title ASC'; 31 31 32 32 try { 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)); 36 36 } catch (Exception $e) { 37 37 $core->error->add($e->getMessage()); 38 38 } 39 39 40 40 # Actions combo box 41 41 42 $pages_actions_page = new dcPagesActionsPage($core, 'plugin.php',array('p'=>'pages'));42 $pages_actions_page = new dcPagesActionsPage($core, 'plugin.php', array('p' => 'pages')); 43 43 44 44 if (!$pages_actions_page->process()) { 45 45 46 47 46 # --BEHAVIOR-- adminPagesActionsCombo 48 $core->callBehavior('adminPagesActionsCombo',array(&$combo_action));47 $core->callBehavior('adminPagesActionsCombo', array(&$combo_action)); 49 48 50 49 /* Display 51 50 -------------------------------------------------------- */ 52 ?>51 ?> 53 52 <html> 54 53 <head> 55 54 <title><?php echo __('Pages'); ?></title> 56 55 <?php 57 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 56 echo 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>'; 64 63 65 ?>64 ?> 66 65 </head> 67 66 … … 69 68 <?php 70 69 echo dcPage::breadcrumb( 71 72 73 __('Pages')=> ''74 )).dcPage::notices();70 array( 71 html::escapeHTML($core->blog->name) => '', 72 __('Pages') => '' 73 )) . dcPage::notices(); 75 74 76 if (!empty($_GET['upd'])) {77 78 } elseif (!empty($_GET['del'])) {79 80 } elseif (!empty($_GET['reo'])) {81 82 }83 echo84 '<p class="top-add"><a class="button add" href="'.$p_url.'&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 . '&act=page">' . __('New page') . '</a></p>'; 85 84 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">' . 91 89 92 '%s'.90 '%s' . 93 91 94 '<div class="two-cols">'.95 '<p class="col checkboxes-helpers"></p>'.92 '<div class="two-cols">' . 93 '<p class="col checkboxes-helpers"></p>' . 96 94 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 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 ?> 114 112 </body> 115 113 </html>
Note: See TracChangeset
for help on using the changeset viewer.