Plugin Directory

Changeset 1452899


Ignore:
Timestamp:
07/11/2016 06:44:39 PM (10 years ago)
Author:
rootabout
Message:

update to 1.1.1 - added dynamic unlimited inputs functionality

Location:
admin-builder/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • admin-builder/trunk/admin_builder.php

    r1449741 r1452899  
    44  Plugin URI: http://admin-builder.com
    55  Description: A plugin that generates admin panel pages & posts,sidebars,custom admin pages with tabs, custom post types, meta boxes and fields (with unlimited textbox, textarea, checkbox, custom select (dropdown box), datepicker, timepicker, colorpicker, upload media fields, with configurable options) Based on what's exported from http://admin-builder.com
    6   Version: 1.1
     6  Version: 1.1.1
    77  Author: rootabout
    88  Author URI: http://admin-builder.com
  • admin-builder/trunk/css/style.css

    r1449741 r1452899  
    6060    margin: 20px auto;
    6161}
     62.groupContainer{
     63  position: relative;
     64  margin:20px 0;
     65  padding:20px;
     66  background:#d7d7d7;
     67}
     68button.close{
     69  position: absolute;
     70  right:0px;
     71  top:0px;
     72  padding:5px;
     73  float:right;
     74  margin:5px;
     75  font-size: 18px;
     76  color:#9e1c1c;
     77  opacity: 1;
     78}
     79button.close:hover{
     80  background: #9e1c1c;;
     81  opacity: 1;
     82  padding:5px;
     83  color:#FFF;
     84}
  • admin-builder/trunk/inc/abFields.php

    r1449741 r1452899  
    77      {
    88          $sGeneral = new GeneralFunctionality();
     9
    910          switch ($fType) {
    1011        case 'cPage':
     
    232233          $fieldHTML .= '<input type="hidden" class="abBIHidden" name="'.$fieldName.'" value="'.$fieldValue.'" />';
    233234          break;
     235          case 'textboxesDynamic':
     236          // $sGeneral->showArr($fieldValue);
     237
     238          $oArr = (isset($field['oArr']))?$field['oArr']:array();
     239          $fieldHTML .= '<div class="hidden tbdContent">';
     240          $fieldHTML .= '<div class="groupContainer">';
     241          $fieldHTML .= '<button type="button" class="btn btn-primary close">X</button>';
     242          foreach ($oArr as $key) {
     243            $fieldHTML .= $this->dtGenerate($key->label,$fieldName,null,null,$key->value);
     244          }
     245          $fieldHTML .= '</div>';
     246          $fieldHTML .= '</div>';
     247
     248          $imgAlt = '';
     249          $fieldHTML .= '<div class="tdOutput">';
     250          // $sGeneral->showArr($fieldValue);
     251
     252          if(is_array($fieldValue)){
     253          //
     254          $i=0;
     255
     256            foreach ($fieldValue as $fv) {
     257              $fieldHTML .= '<div class="groupContainer">';
     258              $fieldHTML .= '<button type="button" class="btn btn-primary close">X</button>';
     259              foreach ($oArr as $key=>$val) {
     260                $fieldValue = (isset($fv[$val->value]))?$fv[$val->value]:'';
     261                $fieldHTML .= $this->dtGenerate($val->label,$fieldName,$fv[$val->value],$i,$val->value);
     262              }
     263              $fieldHTML .= '</div>';
     264              $i++;
     265            }
     266          }
     267
     268          $fieldHTML .= '</div>';
     269          $fieldHTML .= '<p><button type="button" class="tbdAdd btn btn-primary">Add Row</button><br/></p>';
     270          break;
    234271        }
    235272          ?>
     
    249286
    250287      }
     288      //dynamic textbox generate
     289      private function dtGenerate($label,$name,$value,$index=null,$attr=null){
     290        $arrName = $name;
     291        $origNameStr = 'origName="'.$name.'" ';
     292        if($index!== null && !empty($attr) && !empty($attr)){
     293          $arrName = $name.'['.$index.']['.$attr.']';
     294        }
     295
     296        $attrStr = '';
     297        if($attr!=null && !empty($attr)){
     298          $attrStr = 'dtArrName="'.$attr.'" ';
     299        }
     300        $fieldHTML = '<div class="form-group">';
     301        $fieldHTML .= '<label for="'.$name.'">'.$label.'</label>';
     302        $fieldHTML .= '<input type="text" name="'.$arrName.'" '.$origNameStr.'  class="form-control" '.$attrStr.' placeholder="Please enter '.$label.'" value="'.$value.'">';
     303        $fieldHTML .= '</div>';
     304        return $fieldHTML;
     305      }
    251306    }
    252307}
  • admin-builder/trunk/inc/abGeneral.php

    r1449741 r1452899  
    2222                    //version
    2323                    $dataArrSettings = $dataArr['sett'];
     24
    2425                    $data = stripslashes($dataArrSettings);
    2526                    $dataArrSettings = json_decode($data);
  • admin-builder/trunk/inc/abMeta.php

    r1449741 r1452899  
    132132
    133133                // set the new value to a variable
    134                 $new_meta_value = (isset($_POST[$fieldName]) ? $_POST[$fieldName] : '');
    135                 // $this->showArr($value);
     134                $new_meta_value = (isset($_POST[$fieldName]) ? $_POST[$fieldName] : '0');
    136135                # code...
    137136                /* Get the meta key. */
     
    140139                /* Get the meta value of the custom field key. */
    141140                $meta_value = get_post_meta($post_id, $meta_key, true);
     141                if(is_array($new_meta_value)){
     142                  $tempNewMetaValue = array();
     143                  foreach ($new_meta_value as $key => $value) {
     144                    $tempNewMetaValue[]=$value;
     145                  }
     146                  $new_meta_value = $tempNewMetaValue;
     147                }
    142148
    143149                /* If a new meta value was added and there was no previous value, add it. */
    144                 if ($new_meta_value != '' && '' == $meta_value) {
    145                     add_post_meta($post_id, $meta_key, $new_meta_value);
    146                 } /* If the new meta value does not match the old value, update it. */
    147                 elseif ($new_meta_value !== $meta_value) {
     150                if ($new_meta_value !== $meta_value) {
    148151                    update_post_meta($post_id, $meta_key, $new_meta_value);
    149152                } /* If there is no new meta value but an old value exists, delete it. */
  • admin-builder/trunk/js/script.js

    r1449741 r1452899  
    104104    }
    105105
     106    // textboxesDynamic functionality START
     107    var tbdAdd = $('.tbdAdd'); //add row button
     108    if(tbdAdd[0]){
     109      tbdAdd.click(function(){
     110        var tbdContent = $(this).parent().siblings('.tbdContent');
     111        var tdOutput = $(this).parent().siblings('.tdOutput');
     112        tbdContentHTML = tbdContent.html();
     113        //get the number of dynamic field groups added
     114        var size = tdOutput.find('.groupContainer').size();
     115
     116        var tbdContentHTMLObj = $('<div>'+tbdContentHTML+'</div>');
     117
     118        //get all the inputs of the hidden html
     119        var dtContInputs = tbdContentHTMLObj.find('input');
     120        //for each input
     121        dtContInputs.each(function(index,i){
     122          var thisInput = $(this);
     123          var inputAttr = thisInput.attr('dtArrName');
     124          if(inputAttr[0]){
     125            var thisInputName = thisInput.attr('origName');
     126            var newInputName = thisInputName+'['+size+']['+inputAttr+']';
     127            //set the new name to the input
     128            thisInput.attr('name',newInputName);
     129          }
     130        });
     131        // console.log(size);
     132        tbdContentHTML = tbdContentHTMLObj.html();
     133        tdOutput.append(tbdContentHTML);
     134      });
     135    }
     136    // close button for dynamic fields containers
     137    var dtClose = $('.groupContainer button.close');
     138    if(dtClose[0]){
     139      dtClose.live('click',function(){
     140        var cThis = $(this);//current this
     141        var cc = cThis.parent().parent();
     142        cThis.parent().remove();
     143        dtGenerateNames(cc);
     144
     145      });
     146    }
     147    function dtGenerateNames(parObj){
     148      var groupContainers = parObj.find('.groupContainer');
     149      groupContainers.each(function(cIndex,i){
     150        var gcThis = $(this);
     151        var inputs = gcThis.find('input');
     152        inputs.each(function(iIndex,i){
     153          var iThis = $(this); //this input
     154          var origName = iThis.attr('origName');
     155          var dtArrName = iThis.attr('dtArrName');
     156          iThis.attr('name',origName+'['+cIndex+']['+dtArrName+']');
     157        });
     158      });
     159    }
    106160});
  • admin-builder/trunk/readme.txt

    r1449741 r1452899  
    55Requires at least: 4.0
    66Tested up to: 4.5
    7 Stable tag: 1.1
     7Stable tag: 1.1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    154154  Interpreting new export functionality for themes and plugins, integrated into the plugin.
    155155
     156  = 1.1.1 =
     157  Added Dynamic Textboxes functionality for custom post types and admin pages. You can create unlimited dynamic text boxes of unlimited dynamic text boxes now.
     158
     159
    156160== Arbitrary section ==
    157161
Note: See TracChangeset for help on using the changeset viewer.