Plugin Directory

Changeset 1708107


Ignore:
Timestamp:
08/04/2017 12:05:47 AM (8 years ago)
Author:
ekamiya
Message:

ver.1.0.3; code changes for performance.

Location:
simple-schedule-notice/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • simple-schedule-notice/trunk/class-genfset.php

    r1704139 r1708107  
    88
    99class GenFset_Class {
    10   /*   ** sample html generated :
     10  /*** sample html generated :
    1111   * <fieldset class="<?$fldclass?>">
    1212   *   <legend>Password / Confirm</legend>
     
    6969        case 'Trident':
    7070        case 'Edge':
    71           $stylestr .= $this->Con( $stylestr, ' ' ) . 'width:' . (integer)$opt[ 'sz' ]*0.6 . 'em;';
     71          $stylestr .= $this->con( $stylestr, ' ' ) . 'width:' . (integer)$opt[ 'sz' ]*0.6 . 'em;';
    7272          break;
    7373        default:
    74           $stylestr .= $this->Con( $stylestr, ' ' ) . 'resize: both;';
     74          $stylestr .= $this->con( $stylestr, ' ' ) . 'resize:both;';
    7575          break;
    7676      }
     
    102102          case 'st':
    103103            foreach ( $opval as $stval ) {
    104               $stylestr .= ' ' . $this->strterm( $stval, ';' );
     104              $stylestr .= $this->con( $stylestr, ' ' ) . $this->strterm( $stval, ';' );
    105105            }
    106106            break;
     
    111111            break;
    112112          default:
    113             $genstr .= ' ' . $opkey . '="' . $opval . '"';
     113            $genstr .= $this->con( $genstr, ' ' ) . $opkey . '="' . $opval . '"';
    114114            break;
    115115        }
     
    167167            break;
    168168          default:
    169             $rbstr .= ' ' . $optkey . '="' . $optval . '"';
     169            $rbstr .= $this->con( $rbstr, ' ' ) . $optkey . '="' . $optval . '"';
    170170            break;
    171171        }
     
    174174      $rbstr .=  '>';
    175175      $this->fields[]
    176         = '<label ' . ( empty( $lbsty ) ? '' : ' style="' . $lbsty . '"') . '>' . $rbstr . $label . '</label>';
    177     }
    178   }
    179 
    180   function tag( $tag, $param=array(), $pushstack = True ) {
     176        = '<label' . ( empty( $lbsty ) ? '' : ' style="' . $lbsty . '"') . '>' . $rbstr . $label . '</label>';
     177    }
     178  }
     179
     180  function tag( $tag, $param='', $pushstack = True ) {
    181181  // do not enclose $tag with < >
    182     $str = $tag . ' ' . $this->unstruct( $param );
     182    $ret = $tag;
     183    if ( ! empty( $param )) {
     184      $ret .= ' ' . $param;
     185    }
    183186    if ( $pushstack ) {
    184187      $this->tagstack[ $this->tagcnt++ ] = $tag;
    185       $this->fields[] = $this->Capsul( $str, '<>' );
    186     } else {
    187       $this->plaintext( $str );
    188     }
     188    }
     189    $this->fields[] = $this->capsul( $ret, '<>' );
    189190  }
    190191
     
    195196        $this->fields[] = 'error : tag stack empty.';
    196197      } else {
    197         $this->fields[] = $this->Capsul( $this->tagstack[ --$this->tagcnt ], array( '</', '>' ));
     198        $this->fields[] = $this->capsul( $this->tagstack[ --$this->tagcnt ], array( '</', '>' ));
    198199      }
    199200    }
     
    254255  }
    255256
    256   //** support functions
    257   private function unstruct( $param ) {
    258     //do not use nested definition at this version; will not work properly.
    259     if ( is_array( $param ) ) {
    260       $str = '';
    261       if ( array_values( $param ) === $param ) {    //simple array
    262         foreach ( $param as $value ) {
    263           $str .= $this->unstruct( $value );
    264         }
     257  //**** service methods ****
     258  private function get_liststr( $msg, $gtag='ul', $ltag='li' ) {
     259    //Returns <ul> list from simple array $msg.
     260    $ret = '';
     261    if ( ! empty( $msg )) {
     262      if ( is_array( $msg )) {
     263        $g_opn = $this->capsul( $gtag, '<>' );    $g_cls = $this->capsul( '/' . $gtag, '<>' );
     264        $l_opn = $this->capsul( $ltag, '<>' );    $l_cls = $this->capsul( '/' . $ltag, '<>' );
     265        $ret = $g_opn . $l_opn . implode( $l_cls . $l_opn, $msg ) . $l_cls . $g_cls;
    265266      } else {
    266         foreach ( $param as $key => $value ) {      //associative array
    267           $str .= $key . '=' . $this->Capsul( $this->unstruct( $value ), '"' );
    268         }
    269       }
    270     } else {
    271       $str = $param;
    272     }
    273     return $str;
    274   }
    275 
    276   private function get_liststr( $msg ) {
    277     //simple array $msg returns <ul> list.
    278     $ret = '';
    279     if ( is_string( $msg )) {
    280       $ret = $msg;
    281     } elseif ( is_array( $msg )) {
    282       if ( !empty( $msg )) {
    283         $ret = '<ul>';
    284         foreach ( $msg as $line ) {
    285           $ret .= '<li>' . $line . '</li>';
    286         }
    287          $ret .= '</ul>';
     267        $ret = $msg;
    288268      }
    289269    }
     
    291271  }
    292272
    293   private function Con( $base, $conchar = ' and ', $default = '' ) {
     273  private function con( $base, $conchar = ' and ', $default = '' ) {
    294274    //Returns concatination string.
    295275    return (empty( $base ) ? $default : $conchar);
     
    306286  }
    307287
    308   private function Capsul( $str, $sep="'" ) {
     288  private function capsul( $str, $sep="'" ) {
    309289    if ( is_array( $sep )) {
    310290      $sep_h = $sep[ 0 ];
     
    312292    } else {
    313293      $siz = strlen( $sep );
    314       if ( 2 == $siz ) {
    315         $sep_h = substr( $sep, 0, 1 );
     294      if ( 2 <= $siz ) {
     295        $sep_h = substr( $sep, 0, $siz - 1 );
    316296        $sep_f = substr( $sep, -1, 1 );
    317297      } else {      //expects 1 normally
     
    319299      }
    320300    }
    321     return $sep_h . $str . $sep_f;
     301    $siz = strlen( $sep_h );
     302    return ( $sep_h <> substr( $str, 0, $siz ) ? $sep_h . $str . $sep_f : $str );
    322303  }
    323304
  • simple-schedule-notice/trunk/readme.txt

    r1704140 r1708107  
    44Tags: reminder,notice,notification,schedule,mail
    55Requires at least:
    6 Tested up to: 4.8 (php 5.6.8)
     6Tested up to: 4.8.1 (php 5.6.8)
    77Stable tag: trunk
    88License: GPLv2 or later
     
    4545== Changelog ==
    4646
     47= 1.0.3 =
     48* Code changes for efficiency.
     49
    4750= 1.0.2 =
    4851* Fixed the problem that the width of "textarea" is too small on MSIE and Edge.
  • simple-schedule-notice/trunk/simple-schedule-notice.php

    r1704140 r1708107  
    88  Text Domain: smpl_shcd_notice
    99  Domain Path: /languages
    10   Version: 1.0.2
     10  Version: 1.0.3
    1111 */
    1212include_once 'definitions.php';
     
    108108          $this->update_baseinfo( $baseinfo );
    109109        }
    110         $suppress_list = $this->gen_settingpage( $baseinfo, $err );
     110        $suppress_list = $this->gen_setting_page( $baseinfo, $err );
    111111        break;
    112112      case 'new':             //show detail screen
    113113        $post_id = 0;
    114114        list( $post_info, $post_meta_info ) = $this->get_defaultdata();
    115         $suppress_list = $this->gen_detailpage( $post_id, $post_info, $post_meta_info );
     115        $suppress_list = $this->gen_detail_page( $post_id, $post_info, $post_meta_info );
    116116        break;
    117117      case 'edit':
    118118        $post_id = $this->PVal( $dir, 0 );
    119119        list( $post_info, $post_meta_info ) = $this->get_dbdata( $post_id );
    120         $suppress_list = $this->gen_detailpage( $post_id, $post_info, $post_meta_info );
     120        $suppress_list = $this->gen_detail_page( $post_id, $post_info, $post_meta_info );
    121121        break;
    122122      case 'delete':
     
    134134        $err = $this->check_detailinput( $post_info, $post_meta_info );
    135135        if ( !empty( $err ) ) {
    136           $suppress_list = $this->gen_detailpage( $post_id, $post_info, $post_meta_info, $err );
     136          $suppress_list = $this->gen_detail_page( $post_id, $post_info, $post_meta_info, $err );
    137137        } else {
    138138          $this->update_schedule( $post_id, $post_info, $post_meta_info );
     
    158158    }
    159159    if ( !$suppress_list ) {
    160       $this->gen_settingpage();
     160      $this->gen_setting_page();
    161161    }
    162162  }
    163163
    164164  //generate base info screen
    165   private function gen_settingpage( $baseinfo = null, $err = array() ) {
     165  private function gen_setting_page( $baseinfo = null, $err = array() ) {
    166166    global $post, $authordata;     //setup_postdata requires "global $post" is used
    167167
     
    195195        $fset->open( __( 'Notification Time', cPluginID ) );
    196196        $fid = 'notify_time';
    197         $fset->tag( 'div', array( 'style' => 'display: inline-block;' ));
     197        $fset->tag( 'div', 'style=display: inline-block;' );
    198198          $fset->input( $fid, $baseinfo[ $fid ], array( 'sz'=>10, 'ph' => __( 'Enter notification time.', cPluginID ) ) );
    199           $fset->tag( 'span',  array( 'style'=>'margin-left: 1em;' ) );
     199          $fset->tag( 'span', 'style=margin-left: 1em;' );
    200200          $fset->plaintext( '( 00:00:00 .. 23:59:59 )' );
    201201          $fset->c_tag();
     
    330330
    331331  //generate detail screen
    332   private function gen_detailpage( $post_id, $post_info, $post_meta_info, $err = array() ) {
     332  private function gen_detail_page( $post_id, $post_info, $post_meta_info, $err = array() ) {
    333333    $this->gen_article_hdr( 'shdntc-detail' );
    334334
     
    348348      $cycnam = $this->get_cycle($yr, $mo, $da, 'n');
    349349      $fset->open( __( 'Notification Cycle', cPluginID ) );
    350       $fset->tag( 'p', array( 'style'=>'margin: 0.5em 0em;' ) );
     350      $fset->tag( 'p', 'style=margin: 0.5em 0em;' );
    351351      $fset->radio('cycle', $this->cycledef(), $cycnam, array( 'onClick'=>'cy_ctl()' ));
    352352      $fset->c_tag();
    353       $fset->tag( 'p', array( 'style'=>'margin: 0.5em 0em;' ) );
    354       $fset->tag( 'span', array( 'style'=>'margin-right: 2em;' ) );
     353      $fset->tag( 'p', 'style=margin: 0.5em 0em;' );
     354      $fset->tag( 'span', 'style=margin-right: 2em;' );
    355355      $fset->plaintext( __( 'Year :', cPluginID ) . '&nbsp;' );
    356356      $fset->input( 'YR', $yr, array('im' => 'numeric', 'sz' => 4 ) );
    357357      $fset->c_tag();
    358       $fset->tag( 'span', array( 'style'=>'margin-right: 2em;' ) );
     358      $fset->tag( 'span', 'style=margin-right: 2em;' );
    359359      $fset->plaintext( __( 'Month :', cPluginID ) . '&nbsp;' );
    360360      $fset->input( 'MO', $mo, array('im' => 'numeric', 'sz' => 2 ) );
     
    369369      $fset->close();
    370370      $fset->open( __( 'Common Destinations', cPluginID ) );
    371       $fset->tag( 'span', array( 'class'=>'checkbox_layout' ) );
     371      $fset->tag( 'span', 'class="checkbox_layout"' );
    372372      $fid = 'suppress_default1';
    373373      $fset->checkbox( $fid, __( 'Do not send to destination 1', cPluginID ), $this->AVal( $fid, $post_meta_info, False ) );
     
    394394      $fset->close();
    395395      $fset->open( __( 'Last Processed Date', cPluginID ) );
    396       $fset->tag( 'span', array( 'style'=>'display: inline; vertical-align: middle;' ) );
     396      $fset->tag( 'span', 'style=display: inline; vertical-align: middle;' );
    397397      $fid = 'processed';
    398398      $fset->input( $fid, $this->AVal( $fid, $post_meta_info ), array('ro' => True, 'sz' => 16, 'st'=>array('margin-right: 2em') ) );
     
    920920        break;
    921921      default :
    922         $msg = '( ' . $mid . ' : no translation provided)';
     922        $msg = '( massage ID ' . $mid . ' is not defined. )';
    923923        break;
    924924    }
Note: See TracChangeset for help on using the changeset viewer.