[ Index ] |
MailPress 544 |
[ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] [ Statistics ] |
[Summary view] [Print] [Text view]
1 <?php 2 class MP_AdminPage extends MP_adminpage_list_ 3 { 4 const screen = 'mailpress_tracking_m'; 5 const capability = 'MailPress_tracking_mails'; 6 const help_url = 'http://blog.mailpress.org/tutorials/add-ons/tracking/'; 7 const file = __FILE__; 8 9 //// Title //// 10 11 public static function title() 12 { 13 new MP_Tracking_metaboxes('mail'); 14 15 global $title; 16 $title = __('Tracking', MP_TXTDOM); 17 } 18 19 //// Styles //// 20 21 public static function print_styles($styles = array()) 22 { 23 $styles[] = 'dashboard'; 24 25 wp_register_style ( 'mp_mail', '/' . MP_PATH . 'mp-admin/css/mails.css', array('thickbox') ); 26 $styles[] = 'mp_mail'; 27 28 wp_register_style ( self::screen, '/' . MP_PATH . 'mp-admin/css/tracking_m.css' ); 29 30 $styles[] = self::screen; 31 parent::print_styles($styles); 32 } 33 34 //// Scripts //// 35 36 public static function print_scripts($scripts = array()) 37 { 38 $scripts = apply_filters('MailPress_autorefresh_js', $scripts); 39 40 wp_register_script( 'mp-thickbox', '/' . MP_PATH . 'mp-includes/js/mp_thickbox.js', array('thickbox'), false, 1); 41 42 wp_register_script( self::screen, '/' . MP_PATH . 'mp-admin/js/tracking_t.js', array('mp-thickbox', 'postbox'), false, 1); 43 wp_localize_script( self::screen, 'MP_AdminPageL10n', array( 44 'screen' => self::screen 45 )); 46 47 $scripts[] = self::screen; 48 49 parent::print_scripts($scripts); 50 } 51 52 //// Metaboxes //// 53 54 public static function screen_meta() 55 { 56 do_action('MailPress_tracking_add_meta_box', self::screen); 57 parent::screen_meta(); 58 } 59 60 //// Columns //// 61 62 public static function get_columns() 63 { 64 $columns = array( 'title' => __('Subject', MP_TXTDOM), 65 'author' => __('Author'), 66 'theme' => __('Theme', MP_TXTDOM), 67 'to' => __('To', MP_TXTDOM), 68 'date' => __('Date') ); 69 $columns = apply_filters('MailPress_mails_columns', $columns); 70 return $columns; 71 } 72 73 public static function columns_list($id = true) 74 { 75 $columns = self::get_columns(); 76 $hidden = array(); 77 foreach ( $columns as $key => $display_name ) 78 { 79 $thid = ( $id ) ? " id='$key'" : ''; 80 $class = ( 'cb' === $key ) ? " class='check-column'" : " class='manage-column column-$key'"; 81 $style = ( in_array($key, $hidden) ) ? " style='display:none;'" : ''; 82 83 echo "<th$thid$class$style>$display_name</th>"; 84 } 85 } 86 87 //// Row //// 88 89 public static function get_row( $id, $url_parms, $xtra = false) 90 { 91 global $mp_mail; 92 93 $mp_mail = $mail = MP_Mail::get( $id ); 94 $the_mail_status = $mail->status; 95 96 // url's 97 $args = array(); 98 $args['id'] = $id; 99 $args['action'] = 'iview'; 100 $args['preview_iframe'] = 1; $args['TB_iframe']= 'true'; 101 $view_url = esc_url(self::url(MP_Action_url, $args)); 102 103 // table row 104 // to 105 $draft_dest = MP_User::get_mailinglists(); 106 107 switch (true) 108 { 109 case ($xtra) : 110 $email_display = "<blink style='color:red;font-weight:bold;'>" . $xtra . '</blink>'; 111 break; 112 case (is_email($mail->toemail)) : 113 $mail_url = self::url(MailPress_mails, $url_parms); 114 $mail_url = remove_query_arg('s', $mail_url); 115 $mail_url = esc_url( $mail_url . '&s=' . $mail->toemail ); 116 117 $email_display = ''; 118 119 if ( get_option('show_avatars') ) 120 { 121 $email_display .= "<div style='float:left;margin-right:10px;'>"; 122 $email_display .= get_avatar( $mail->toemail, 32 ); 123 $email_display .= '</div>'; 124 } 125 $email_display .= "<div style='float:left;'>"; 126 $email_display .= '<strong>'; 127 $email_display .= ( strlen($mail->toemail) > 40 ) ? substr($mail->toemail, 0, 39) . '...' : $mail->toemail; 128 $email_display .= '</strong>'; 129 if (!empty($mail->toname)) $email_display .= '<br />' . $mail->toname; 130 $email_display .= '</div>'; 131 break; 132 case (isset($draft_dest[$mail->toemail])) : 133 $email_display = "<strong>" . $draft_dest[$mail->toemail] . "</strong>"; 134 break; 135 case (is_serialized($mail->toemail)) : 136 $email_display = "<div class='num post-com-count-wrapper'><a class='post-com-count'><span class='comment-count'>" . count(unserialize($mail->toemail)) . "</span></a></div>"; 137 break; 138 default : 139 $email_display = "<span style='color:red;font-weight:bold;'>" . __('(unknown)', MP_TXTDOM) . '</span>'; 140 unset($actions['send']); 141 break; 142 } 143 $email_display = apply_filters('MailPress_to_mails_column', $email_display, $mail); 144 if ($mailinglist_desc = MP_Mail_meta::get($mail->id, '_mailinglist_desc')) $email_display = "<div>{$email_display}</div>{$mailinglist_desc}"; 145 // author 146 $author = ( 0 == $mail->sent_user_id) ? $mail->created_user_id : $mail->sent_user_id; 147 if ($author != 0 && is_numeric($author)) 148 { 149 unset($url_parms['author']); 150 $wp_user = get_userdata($author); 151 } 152 // subject 153 $metas = MP_Mail_meta::get( $id, '_MailPress_replacements'); 154 $subject_display = $mail->subject; 155 if ($metas) foreach($metas as $k => $v) $subject_display = str_replace($k, $v, $subject_display); 156 // attachements 157 $attach = false; 158 $metas = MP_Mail_meta::has( $id, '_MailPress_attached_file'); 159 if ($metas) 160 { 161 foreach($metas as $meta) 162 { 163 $meta_value = unserialize( $meta['meta_value'] ); 164 if (is_file($meta_value['file_fullpath'])) 165 { 166 $attach = true; 167 break; 168 } 169 } 170 } 171 ?> 172 <tr id="mail-<?php echo $id; ?>"> 173 <?php 174 $columns = self::get_columns(); 175 176 foreach ( $columns as $column_name => $column_display_name ) 177 { 178 $class = "class='$column_name column-$column_name'"; 179 $style = ''; 180 if ('unsent' == $mail->status) $style .= 'font-style:italic;'; 181 $style = ' style="' . $style . '"'; 182 183 $attributes = "$class$style"; 184 185 switch ($column_name) 186 { 187 case 'title': 188 $attributes = 'class="post-title column-title"' . $style; 189 ?> 190 <td <?php echo $attributes ?>> 191 <?php 192 if ('paused' == $mail->status) : 193 ?> 194 <span class='icon paused' title="<?php _e('Paused', MP_TXTDOM); ?>"></span> 195 <?php 196 endif; 197 if ($attach) : 198 ?> 199 <span class='icon attachement' title="<?php _e('Attachments', MP_TXTDOM); ?>"></span> 200 <?php 201 endif; 202 203 do_action('MailPress_get_icon_mails', $id); 204 ?> 205 <strong> 206 <a class='row-title thickbox thickbox-preview' href='<?php echo $view_url; ?>' title='<?php printf( __('View "%1$s"', MP_TXTDOM) , ( '' == $subject_display) ? __('(no subject)', MP_TXTDOM) : htmlspecialchars($subject_display, ENT_QUOTES) ); ?>'> 207 <?php echo ( '' == $subject_display) ? __('(no subject)', MP_TXTDOM) : (( strlen($subject_display) > 40 ) ? $subject_display = mb_substr($subject_display, 0, 39, get_option('blog_charset')) . '...' : $subject_display); ?> 208 </a> 209 <?php if ('paused' == $mail->status) echo ' - ' . __('Paused', MP_TXTDOM); ?> 210 <?php if ('archived' == $mail->status) echo ' - ' . __('Archive', MP_TXTDOM); ?> 211 </strong> 212 </td> 213 <?php 214 break; 215 case 'author': 216 ?> 217 <td <?php echo $attributes ?>> 218 <?php if ($author != 0 && is_numeric($author)) { ?> 219 <?php echo $wp_user->display_name; ?> 220 <?php } else _e("(unknown)", MP_TXTDOM); ?> 221 </td> 222 <?php 223 break; 224 case 'theme': 225 ?> 226 <td <?php echo $attributes ?>> 227 <?php echo $mail->theme; ?> 228 <?php if ('' != $mail->template) echo "<br />(" . $mail->template . ")"; ?> 229 </td> 230 <?php 231 break; 232 case 'to': 233 ?> 234 <td <?php echo $attributes ?>> 235 <?php echo $email_display; ?> 236 </td> 237 <?php 238 break; 239 case 'date': 240 241 $t_time = self::get_mail_date(__('Y/m/d H:i:s')); 242 $h_time = self::human_time_diff(self::get_mail_date_raw()); 243 ?> 244 <td <?php echo $attributes ?>> 245 <abbr title="<?php echo $t_time; ?>"><?php echo $h_time; ?></abbr> 246 </td> 247 <?php 248 break; 249 default: 250 ?> 251 <td <?php echo $attributes ?>> 252 <?php do_action('MailPress_mails_get_row', $column_name, $mail, array()); ?> 253 </td> 254 <?php 255 break; 256 } 257 } 258 ?> 259 </tr> 260 <?php 261 } 262 263 public static function mail_date($d = '') { 264 echo self::get_mail_date($d); 265 } 266 267 public static function get_mail_date($d = '' ) { 268 $x = self::get_mail_date_raw(); 269 return ( '' == $d ) ? mysql2date( get_option('date_format'), $x) : mysql2date($d, $x); 270 } 271 272 public static function get_mail_date_raw() { 273 global $mp_mail; 274 $x = ($mp_mail->sent >= $mp_mail->created) ? $mp_mail->sent : $mp_mail->created; 275 return $x; 276 } 277 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Apr 28 18:38:52 2016 | Cross-referenced by PHPXref 0.7.1 |