[26089] | 1 | <?php |
---|
| 2 | defined('COA_ID') or die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | function coa_albums() |
---|
| 5 | { |
---|
| 6 | global $page; |
---|
| 7 | |
---|
| 8 | if (!empty($page['section']) and $page['section'] == 'categories' and |
---|
| 9 | isset($page['category']) and $page['body_id'] == 'theCategoryPage' |
---|
| 10 | ) |
---|
| 11 | { |
---|
| 12 | trigger_notify('loc_begin_coa'); |
---|
| 13 | include(COA_PATH . 'include/coa_albums.php'); |
---|
| 14 | } |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | function coa_comments() |
---|
| 18 | { |
---|
| 19 | include(COA_PATH . 'include/coa_comments_page.php'); |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | function coa_admin_intro() |
---|
| 23 | { |
---|
| 24 | global $page; |
---|
| 25 | |
---|
| 26 | if ($page['page'] == 'intro') |
---|
| 27 | { |
---|
| 28 | global $template; |
---|
| 29 | |
---|
| 30 | // comments count |
---|
| 31 | $query = ' |
---|
| 32 | SELECT COUNT(*) |
---|
| 33 | FROM '.COA_TABLE.' |
---|
| 34 | ;'; |
---|
| 35 | list($nb_comments) = pwg_db_fetch_row(pwg_query($query)); |
---|
| 36 | |
---|
| 37 | $template->assign( |
---|
| 38 | 'DB_COMMENTS_ALBUMS', |
---|
| 39 | l10n_dec('%d comment on album', '%d comments on albums', $nb_comments) |
---|
| 40 | ); |
---|
| 41 | |
---|
| 42 | if ($nb_comments) |
---|
| 43 | { |
---|
| 44 | // unvalidated comments |
---|
| 45 | $query = ' |
---|
| 46 | SELECT COUNT(*) |
---|
| 47 | FROM '.COA_TABLE.' |
---|
| 48 | WHERE validated=\'false\' |
---|
| 49 | ;'; |
---|
| 50 | list($nb_comments) = pwg_db_fetch_row(pwg_query($query)); |
---|
| 51 | |
---|
| 52 | if ($nb_comments > 0) |
---|
| 53 | { |
---|
| 54 | $template->assign(array( |
---|
| 55 | 'U_COMMENTS_ALBUMS' => COA_ADMIN, |
---|
| 56 | 'NB_PENDING_COMMENTS_ALBUMS' => $nb_comments, |
---|
| 57 | )); |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | $template->set_prefilter('intro', 'coa_admin_intro_prefilter'); |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | function coa_admin_intro_prefilter($content) |
---|
| 66 | { |
---|
| 67 | $search = '(<a href="{$U_COMMENTS}">{\'%d waiting for validation\'|translate:$NB_PENDING_COMMENTS}</a>){/if}'; |
---|
| 68 | |
---|
| 69 | $add = ' |
---|
| 70 | </li> |
---|
| 71 | {/if} |
---|
| 72 | {if isset($DB_COMMENTS_ALBUMS)} |
---|
| 73 | <li> |
---|
| 74 | {$DB_COMMENTS_ALBUMS}{if isset($NB_PENDING_COMMENTS_ALBUMS)} (<a href="{$U_COMMENTS_ALBUMS}">{\'%d waiting for validation\'|translate:$NB_PENDING_COMMENTS_ALBUMS}</a>){/if}'; |
---|
| 75 | |
---|
| 76 | return str_replace($search, $search.$add, $content); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | function coa_tabsheet_before_select($sheets, $id) |
---|
| 81 | { |
---|
| 82 | if ($id == 'comments') |
---|
| 83 | { |
---|
| 84 | $sheets['']['caption'] = l10n('Comments on photos'); |
---|
| 85 | $sheets['']['url'] = get_root_url().'admin.php?page=comments'; |
---|
| 86 | |
---|
| 87 | $sheets['albums'] = array( |
---|
| 88 | 'caption' => l10n('Comments on albums'), |
---|
| 89 | 'url' => COA_ADMIN, |
---|
| 90 | ); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | return $sheets; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | function coa_register_stuffs_module($modules) |
---|
| 97 | { |
---|
| 98 | $modules[] = array( |
---|
| 99 | 'path' => COA_PATH . '/stuffs_module', |
---|
| 100 | 'name' => l10n('Last comments on albums'), |
---|
| 101 | 'description' => l10n('Display last posted comments on albums'), |
---|
| 102 | ); |
---|
| 103 | |
---|
| 104 | return $modules; |
---|
| 105 | } |
---|