Skip to content

Latest commit

 

History

History
69 lines (67 loc) · 18.4 KB

SNIPPETS-LIST.md

File metadata and controls

69 lines (67 loc) · 18.4 KB

Disclaimer: I will be getting rid of all extra 'f' keys as there are many functions in this list. For example, Trongate Add Floating Cents Function is not 'tgafcf'. It is only 'tgafc' then hit the Tab key. Enjoy the added speed using these snippets!

Table of Trongate snippets

Snippet Name Shortcut Code Characters saved
Trongate Add Floating Cents Function (Two Variables Passed) tgafc + <Tab> + your amount in dollars number_format($your_amount, 2); 15
Trongate Anchor Function tga + <Tab> + your link anchor('your_link'); 7
Trongate Class tgc + <Tab> + Enter Your Classname + <Tab> + Enter your Class statements class MyClass extends Trongate { Your code goes here. } 25
Trongate Config Array Assignment tgcaa + <Tab> + your first variable name + <Tab> + your second variable name config[$your_variable1] = $your_variable2; 8
Trongate Data Array Assignment tgdaa + <Tab> + your array name + <Tab> + your function name $your_arrayName = 'your_function_name'; 2
Trongate Data String Assignment tgdsa + <Tab> + your view file name $data['view_file'] = 'your_view_file'; 19
Trongate Echo Current Url Function tgecu + <Tab> Press <Tab> to move the cursor after the semicolon echo current_url('your url'); 14
Trongate Echo Form Input Function tgefif + <Tab> + form name + <Ctrl> + >Enter< echo form_input('$form_name'); 15
Trongate Echo Form Label Function tgeflf + <Tab> + your label + <Ctrl + Enter> echo form_input('form_label'); 14
Trongate Echo Form Submit Function tgefsf + <Tab> + <Ctrl> + <Enter> echo form_submit('submit', 'Submit'); 31
Trongate Echo String Function tgesf + <Tab> echo 'my_string'; 3
Trongate Form Close Function tgfcf + <Tab> form_close(); 8
Trongate Form File Select Function (Two Variables Passed) tgffs + <Tab> + form name + <Tab> + form attributes form_file_select('form_name', 'form_attributes'); 18
Trongate Form File Select Function (Three Variables Passed) tgffs3 + <Tab> + form name + <Tab> + form attributes + <Tab> + form additional code form_file_select('form_name', 'form_attributes', 'form_additional_code'); 18
Trongate Form Open Function tgfof + <Tab> form_open('form_location') 8
Trongate Form Open Upload Function tgfou + <Tab> + your form's location + <Tab> the attributes + <Tab> any additional code form_open_upload($form_location, $attributes, $additional_code); 20
Trongate Form Textarea Function tgeft + <Tab> + your text echo form_textarea('your_text'); 17
Trongate Function tgf + your code function your_function() {
   your code goes here
}
14
Trongate Get Nice Date Class tggnd + <Tab> class TimeDate {
   function get_nice_date($timestamp, $format) {
     switch ($format) {
         case 'full':
            //FULL
            //Friday 18th of February 2011 at 10:00:00 AM
            $the_date = date('l jS \of F Y \a\t h:i:s A', $timestamp);
            break;
         case 'cool':
            //FULL
            // Friday 18th of February 2011
            $the_date = date('l jS \of F Y', $timestamp);
            break;
         case 'shorter':
            //SHORTER
            // 18th of February 2011
            $the_date = date('jS \of F Y', $time_stamp);
            break;
         case 'american':
            //AMERICAN
            // February 18th 2011
            $the_date = date('F jS Y', $timestamp);
            break;
         case 'mini':
            //MINI
            // 18th Feb 2011
            $the_date = date('jS M Y'), $timestamp);
            break;
         case 'oldschool':
            //OLDSCHOOL
            // 18/2/11
            $the_date = ('j/n/y', $timestamp);
            break;
         case 'datepicker':
            //DATEPICKER
            // 18/2/11
            $the_date = date('d/m/Y'), $timestamp);
         break; case 'datepicker_us':
            //DATEPICKER_US
            // 2/18/11
            $the_date = date('m/d/Y', $timestamp);
            break;
         case 'dateandtimepicker':
            //DATEANDTIMEPICKER
            // 27th July 2018 - 03:50 pm
            $the_date = date('d F Y - H:i a', $timestamp);
            break;
         case 'monyear':
            //MONYEAR
            // 18th Feb 2011
            $the_date = date('F Y', $timestamp);
            break;
   }

   return $the_date;
}

function _is_datepicker_valid($datepicker) {
   $datepicker_less_slashes = str_replace('/' '', $datepicker);
   $len = strlen($datepicker_less_slashes);
   if ((!is_numeric($datepicker_less_slashes)) or ($len !== 8)) {
         return FALSE;
   } else {
   return TRUE;
   }
}

function get_nice_date_from_datepicker($datepicker, $format) {
   $is_valid = $this->_is_datepicker_valid($datepicker);
   if ($is_valid == TRUE) {
      $timestamp = $this->make_timestamp_from_datepicker($datepicker);
      $nice_date = $this->get_nice_date($timestamp, $format);
   } else {
      $nice_date = '-';
   }
   return $nice_date;
}

function make_timestamp_from_datepicker($datepicker) {
   $hour = 7;
   $minute = 0;
   $second = 0;
   $day = substr($datepicker, 0, 2);
   $month = substr($datepicker, 3, 2);
   $year = substr($datepicker, 6, 4);
   $timestamp = mktime($hour, $minute, $month, $day, $year);
   return $timestamp;
}

function make_timestamp_from_dateandtimepicker($dateandtimepicker) {
   $dateandtimepicker = str_replace('-', '', $dateandtimepicker);
   $timestamp = strtotime($dateandtimepicker);
   return $timestamp;
}      

function make_timestamp_from_datepicker_us($datepicker) {
      $hour = 7;
      $minute = 0;
      $second = 0;
      $month = substr($datepicker, 0 ,2);
      $day = substr($datepicker, 3, 2);
      $year = substr($datepicker, 6, 4);>
      $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
      return $timestamp;
}

function make_timestamp($day, $month, $year) {
      $hour = 7;
      $minute = 0;
      $second = 0;
      $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
      return $timestamp;
   }
};
2897
Trongate HTML BASE_URL tghbu + <Tab> + Press <Tab> to move the cursor after the closing PHP tag <?= BASE_URL ?> 9
Trongate HTML Flash Data tghfd + <Tab> <?= flashdata() ?> 12
Trongate HTML Validation Errors tghve + <Tab> <?= validation_errors() ?> 21
Trongate HTML Variable tghv + <Tab> + Press <Tab> to move the cursor after the closing PHP tag <?= $your_variable ?> 3
Trongate Logic Expression tgle + <Tab> + enter your value + Press <Tab> + enter your expression your_variable = your_expression; -1
Trongate Logic If Else tglie + <Tab> + enter your IF condition + Press <Tab> + enter the code inside the condition + Press <Tab> + enter the code for the else condition if (condition) {
   if-statements;
} else {
   else-statements;
}
26
Trongate Logic If ElseIf tglei + <Tab> + enter your IF condition + Press <Tab> + enter your code inside the condition + Press <Tab> + enter your ELSEIF condition + Press <Tab> + enter the code for the ELSEIF condition + Press <Tab> + enter your code for the ELSE condition if (condition) {
   if-statements;
} elseif (elseif-condition) {
   elseif-statements;
} else {
   else-statements;
}
19
Trongate Method (No Variables Passed) tgm + <Tab> + name your function + <Tab> to move the cursor to the method statements function your_function() {
   Your method code goes here.
}
11
Trongate Method (One Variable Passed) tgm1 + <Tab> + name your function + <Tab> + name of your variable to pass + <Tab> to move cursor to method statements function your_function(your_variable1) {
   Your method code goes here.}
7
Trongate Method (Two Variables Passed) tgm2 + <Tab> + name your function + <Tab> + name of your first variable to pass + <Tab> + name of your second variable to pass <Tab> to move cursor to method statements function your_function(your_variable1, your_variable2) {
   Your method code goes here.
}
8
Trongate Method (Three Variables Passed) tgm3 + <Tab> + name your function + <Tab> + name of your first variable to pass + <Tab> + name of your second variable to pass <Tab> + name of your third variable to pass + <Tab> to move cursor to method statements function your_function(your_variable1, your_variable2, your_variable3) { Your method code goes here. } 11
Trongate Model Delete Function tgmd + <Tab> + number / id in table to delete + <Tab> + table name for deletion $this->model->delete(id, 'tableName'); 19
Trongate Model Get Function (Two Variables Passed) tgmg + <Tab> + enter which way you want the model ordered by + <Tab> + your target table $this->model->get('order_by', 'target_tbl'); 16
Trongate Model Get Function (Three Variables Passed) tgmg3 + <Tab> + enter which way you want the model ordered by + <Tab> + your target table <Tab> + your limit $this->model->get('order_by', 'target_tbl', 'limit'); 22
Trongate Model Get Function (Four Variables Passed) tgmg4 + <Tab> + enter which way you want the model ordered by + <Tab> + your target table <Tab> + your limit + <Tab> + your offset $this->model->get('order_by', 'target_tbl', 'limit', 'offset'); 26
Trongate Model Getwhere Function tgmgw + <Tab> + target id + + target table name $this->model->get_where('id', 'target_tbl'); 25
Trongate Model Insert Function (Two Variables Passed) tgmi + <Tab> + data + <Tab> + target table name $this->model->insert('data', 'target_tbl'); 23
Trongate Model Update Function (Three Variables Passed) tgmu + <Tab> + enter update id + <Tab> + enter record name + <Tab> + enter table name $this->model->update('update_id', 'record_name', 'table_name'); 26
Trongate Module Load Function tgmf + <Tab> + enter your module name $this->module('module_name'); 14
Trongate Modules Run Function tgmrf + <Tab> name of your module <?= Modules::run('module_name/function_name') ?>) 19
Trongate PHP Split tgps + <Tab> <?php 3
Trongate Private Function tgpf + &lgt;Tab> function _myFunction() { your code goes here } 15
Trongate Private This Function (One Variable Passed) tgptf1 + <Tab> + your function name + <Tab> + your passing variable $this->_your_function($your_variable); 4
Trongate Private This Function (Two Variables Passed) tgptf2 + <Tab> + your function name + <Tab> + your first passing variable + <Tab> + your second passing variable $this->_your_function($your_variable1, $your_variable2); 7
Trongate Private This Function (Three Variables Passed) tgptf3+ <Tab> + your function name + <Tab> + your first passing variable + <Tab> + your second passing variable + <Tab> + your third passing variable $this->_your_function($your_variable1, $your_variable2, $your_variable3); 10
Trongate Redirect Function tgr + <Tab> + your target url + <Ctrl + Enter> redirect('your_target_url'); 8
Trongate Set Flash Data Function (One Variable Passed) tgsf + <Tab> + your message set_flashdata('your_message'); 13
Trongate String Replace URL Function tgsru + <Tab> + your first variable + <Tab> + your second variable + <Tab> + the name of your web addresss + <Tab> + your third variable str_replace('your_variable1', 'your_variable2', your_url_name(your_variable3)); 18
Trongate Template Display Data (One Variable Passed) tgtd + <Tab> + your view file or module name <?= Template::display('view_file_or_module_name') ?> 23
Trongate Template Function (No Variables Passed) tgt + <Tab> + your template name $this->template('template_name'); 16
Trongate Template Function (Two Variables Passed) tgt2 + <Tab> + your template name + <Tab> + your view file or module name $this->template('template_name', 'view_file_or_module_name'); 19
Trongate Template Partial (No Variables Passed) tgtp + <Tab> + your file name <?= Template::partial('your_filename') ?> 24
Trongate Template Partial (Two Variables Passed) tgtp2 + <Tab> + your file name + <Tab> + your view file or module name' <?= Template::partial('your_filename', 'view_file_or_module_name') ?> 28
Trongate This Custom Function tgtcf + <Tab> $this->your_function(); 5
Trongate This Input String True Function tgtisitf + <Tab> your string + <Tab> + your variable $this->input('your_string', variable_name); 13
Trongate This Input Submit Function tgtisf + <Tab> $this->input('submit', true); 23
Trongate This Model Insert Function tgtmif + <Tab> + model name $this->model('model_name'); 10
Trongate This Module Function tgtmf + <Tab> + your module name $this->module('your_module'); 13
Trongate This Module Function Function tgtmff + <Tab> + your module + your function name $this->your_module->your_function(); 6
Trongate This Private Functione tgtpf + <Tab> + function name $this->_function_name(); 6
Trongate This View Function tgtvf + <Tab> + your view name $this->view('your_view'); 16
Trongate Url Segment Function tgus + <Tab> + your segment number $this->url->segment($your_segment_number); 18
Trongate Validation Helper Run Function tgvhr + <Tab> + your variable name $your_variable_name = $this->validation_helper->run(); 31
Trongate This Validation Helper Set Rules Function (Three Variables Passed) tgtvhsr + <Tab> + your key + <Tab> + your label name + <Tab> + your rules $this->validation_helper->set_rules('your_key', 'your_label', 'your_rules'); 39