about.php
11 years ago
editor.php
11 years ago
feedback.php
11 years ago
manager.php
11 years ago
metabox.php
11 years ago
settings.php
11 years ago
manager.php
151 lines
| 1 | <?php |
| 2 | //column renderer |
| 3 | function tcm_ui_manager_column($active, $values=NULL, $hide=FALSE) { |
| 4 | global $tcm; |
| 5 | ?> |
| 6 | <td style="text-align:center;"> |
| 7 | <?php |
| 8 | if($hide) { |
| 9 | $text='-'; |
| 10 | } else { |
| 11 | if($active) { |
| 12 | $text='<span style="font-weight:bold; color:green">'.$tcm->Lang->L('Yes').'</span>'; |
| 13 | } else { |
| 14 | $text='<span style="font-weight:bold; color:red">'.$tcm->Lang->L('No').'</span>'; |
| 15 | } |
| 16 | if($active && $values) { |
| 17 | if(!is_array($values)) { |
| 18 | $text.=' {'.$values.'}'; |
| 19 | } elseif(count($values)>0) { |
| 20 | $what=implode(',', $values); |
| 21 | if($what!='') { |
| 22 | $text.=' ['.$what.']'; |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | echo $text; |
| 28 | ?> |
| 29 | </td> |
| 30 | <?php |
| 31 | } |
| 32 | |
| 33 | function tcm_ui_free_notice() { |
| 34 | global $tcm; |
| 35 | |
| 36 | if($tcm->Manager->rc()<=0) { |
| 37 | $tcm->Options->pushErrorMessage('FreeLicenseReached'); |
| 38 | } elseif($tcm->Manager->count()>0) { |
| 39 | $tcm->Options->pushSuccessMessage('PluginLimit.Line1', 6, $tcm->Manager->rc()); |
| 40 | $tcm->Options->pushSuccessMessage('PluginLimit.Line2', TCM_PAGE_PREMIUM); |
| 41 | } |
| 42 | $tcm->Options->writeMessages(); |
| 43 | } |
| 44 | function tcm_ui_manager() { |
| 45 | global $tcm; |
| 46 | |
| 47 | $id=intval($tcm->Utils->qs('id', 0)); |
| 48 | if ($tcm->Utils->is('action', 'delete') && $id>0 && wp_verify_nonce($tcm->Utils->qs('tcm_nonce'), 'tcm_delete')) { |
| 49 | $snippet = $tcm->Manager->get($id); |
| 50 | if ($tcm->Manager->remove($id)) { |
| 51 | $tcm->Options->pushSuccessMessage('CodeDeleteNotice', $id, $snippet['name']); |
| 52 | } |
| 53 | } elseif($id>0) { |
| 54 | $snippet=$tcm->Manager->get($id); |
| 55 | if($tcm->Utils->is('action', 'toggle') && $id>0 && wp_verify_nonce($tcm->Utils->qs('tcm_nonce'), 'tcm_toggle')) { |
| 56 | $snippet['active']=($snippet['active']==0 ? 1 : 0); |
| 57 | $tcm->Manager->put($snippet['id'], $snippet); |
| 58 | } |
| 59 | $tcm->Options->pushSuccessMessage('CodeUpdateNotice', $id, $snippet['name']); |
| 60 | } |
| 61 | |
| 62 | $tcm->Options->writeMessages(); |
| 63 | tcm_ui_free_notice(); |
| 64 | |
| 65 | //controllo che faccio per essere retrocompatibile con la prima versione |
| 66 | //dove non avevo un id e salvavo tutto con il con il nome quindi una stringa |
| 67 | $snippets=$tcm->Manager->keys(); |
| 68 | foreach($snippets as $v) { |
| 69 | $snippet=$tcm->Manager->get($v, FALSE, TRUE); |
| 70 | if(!$snippet) { |
| 71 | $tcm->Manager->remove($v); |
| 72 | } elseif(!is_numeric($v)) { |
| 73 | $tcm->Manager->remove($v); |
| 74 | $tcm->Manager->put('', $snippet); |
| 75 | } |
| 76 | } |
| 77 | $snippets=$tcm->Manager->values(); |
| 78 | if (count($snippets)>0) { ?> |
| 79 | <div style="float:left;"> |
| 80 | <form method="get" action="" style="margin:5px;" class="alignright"> |
| 81 | <input type="hidden" name="page" value="<?php echo TCM_PLUGIN_NAME?>" /> |
| 82 | <input type="hidden" name="tab" value="<?php echo TCM_TAB_EDITOR?>" /> |
| 83 | <input type="submit" class="button-primary" value="<?php $tcm->Lang->P('Button.Add')?>" /> |
| 84 | </form> |
| 85 | <form method="get" style="margin:5px;" class="alignright" action="<?php echo TCM_PAGE_PREMIUM?>"> |
| 86 | <input type="submit" class="button" value="<?php $tcm->Lang->P('Button.BuyPRO')?>" /> |
| 87 | </form> |
| 88 | </div> |
| 89 | <div style="clear:both;"></div> |
| 90 | |
| 91 | <style> |
| 92 | .widefat th { |
| 93 | font-weight: bold!important; |
| 94 | } |
| 95 | </style> |
| 96 | <table class="widefat fixed" style="width:850px;"> |
| 97 | <thead> |
| 98 | <tr> |
| 99 | <th><?php $tcm->Lang->P('Name')?></th> |
| 100 | <th><?php $tcm->Lang->P('Position')?></th> |
| 101 | <th style="text-align:center;"><?php $tcm->Lang->P('Active?')?></th> |
| 102 | <th style="text-align:center;"><?php $tcm->Lang->P('Each pages?')?></th> |
| 103 | <th style="text-align:center;"><?php $tcm->Lang->P('Count')?></th> |
| 104 | <th style="text-align:center;"><?php $tcm->Lang->P('Actions')?></th> |
| 105 | </tr> |
| 106 | </thead> |
| 107 | <tbody> |
| 108 | <?php foreach ($snippets as $snippet) { ?> |
| 109 | <tr> |
| 110 | <td><?php echo $snippet['name']?></td> |
| 111 | <td><?php $tcm->Lang->P('Editor.position.'.$snippet['position'])?></td> |
| 112 | <td style="text-align:center;"> |
| 113 | <?php |
| 114 | $color='red'; |
| 115 | $text='No'; |
| 116 | $question='QuestionActiveOn'; |
| 117 | if($snippet['active']==1) { |
| 118 | $color='green'; |
| 119 | $text='Yes'; |
| 120 | $question='QuestionActiveOff'; |
| 121 | } |
| 122 | $text='<span style="font-weight:bold; color:'.$color.'">'.$tcm->Lang->L($text).'</span>'; |
| 123 | ?> |
| 124 | <a onclick="return confirm('<?php echo $tcm->Lang->L($question)?>');" href="<?php echo TCM_TAB_MANAGER_URI?>&tcm_nonce=<?php echo esc_attr(wp_create_nonce('tcm_toggle')); ?>&action=toggle&id=<?php echo $snippet['id'] ?>"> |
| 125 | <?php echo $text?> |
| 126 | </a> |
| 127 | </td> |
| 128 | <?php |
| 129 | $hide=!$snippet['active']; |
| 130 | tcm_ui_manager_column($snippet['includeEverywhereActive'], NULL, $hide); |
| 131 | ?> |
| 132 | <td style="text-align:center;"><?php echo $snippet['codesCount']?></td> |
| 133 | <td style="text-align:center;"> |
| 134 | <a href="<?php echo TCM_TAB_EDITOR_URI?>&id=<?php echo $snippet['id'] ?>"> |
| 135 | <?php echo $tcm->Lang->L('Edit')?> |
| 136 | </a> |
| 137 | | |
| 138 | <span class="trash"> |
| 139 | <a onclick="return confirm('<?php echo $tcm->Lang->L('Are you sure you want to delete this code?')?>');" href="<?php echo TCM_TAB_MANAGER_URI?>&tcm_nonce=<?php echo esc_attr(wp_create_nonce('tcm_delete')); ?>&action=delete&id=<?php echo $snippet['id'] ?>"> |
| 140 | <?php echo $tcm->Lang->L('Delete')?> |
| 141 | </a> |
| 142 | </span> |
| 143 | </td> |
| 144 | </tr> |
| 145 | <?php } ?> |
| 146 | </tbody> |
| 147 | </table> |
| 148 | <?php } else { ?> |
| 149 | <h2><?php $tcm->Lang->P('EmptyTrackingList', TCM_TAB_EDITOR_URI)?></h2> |
| 150 | <?php } ?> |
| 151 | <?php } |