ATK Code Generator

ATK Code Generator is a robust application designed to assist PHP developers in generating web applications relatively fast without any coding. The system provides a set of wizards which walks through the existing database tables forming relationships as necessary to minimize the amount of time a developer has to spend in customizing the application.

The generated code is designed to work with the powerful ATK framework, which may be easily customized to fit any need. Feel free to view the screenshots, demos and generated code.

As soon as you're ready to be truely productive with ATK, you may download the ATK Code Generator.

Enjoy,

Jorge Garifuna
Web Developer
info@gariDigital.com



Database tables list (click to view larger)
Nodes detail Options for code generation (click to view larger)
Add mode of generated sample node
Admin list of generated sample node
View mode of generated sample node
Simple demo creating activity note node
 
 
Click on the desired version below to download this application
Version Date
2.2 1/19/07
1.1.24 12/22/06
1.1.18 10/20/06
1.1.17 9/30/06
1.1.14 7/23/06
1.1.13 7/14/06
1.1.12 6/28/06
1.1.11 6/20/06
1.1.10 6/18/06
1.1.9 6/16/06
1.1.8 6/14/06
1.1.7 6/14/06
1.1.6 6/13/06
1.1.5 6/12/06
1.1.4 6/8/06
1.1.3 6/8/06
1.1 6/6/06
1.0 6/4/06
   

Click here to download the latest version of ATK.
Source code example generated by the ATK Code Generator for a node called activity_note




/***********************************************************************
	ATK Node: activity_note
	Table: activity_note
	Date: 12/22/06

	
	This code was automatically generated by ATK Code Generator v1.1.24
	
	@Author Jorge Garifuna (GariDigital.com) 
	
	Your are free to modify this code to fit your needs. 
	All I ask for is for your to keep this notice on top of the code
************************************************************************/		
			

atkimport("atk.utils.atkmessagequeue");
useattrib("atknumberattribute");
useattrib("atkattribute");
useattrib("atkfileattribute");
useattrib("atkfckattribute");
useattrib("atkboolattribute");
useattrib("atkdatetimeattribute");

useattrib("atkrowcounter");
class activity_note extends atkNode{

		var $table = "activity_note";
		var $primary_field = "activity_note_id";
		var $module = "test";
		var $node = "activity_note";
		var $index_field = "subject";
		var $order_field = "subject";
		var $descriptor_field = "[subject]";

		// start constructor
		function activity_note(){
			// tabs labels

			// call constructor parent
			$this->atkNode($this->node,NF_ADD_LINK | NF_MRA | NF_TRACK_CHANGES | NF_ADDAFTERADD);

			//event log
			$this->addListener(atknew("atk.utils.atkeventlog"));
			// node attributes
			$this->add(new atkRowCounter("#"),NULL,1);
			$this->add(new atkNumberAttribute("activity_note_id", AF_PRIMARY|AF_HIDE ,10,0),NULL,0);
			$this->add(new atkNumberAttribute("activity_item_id", AF_OBLIGATORY,10,0),NULL,100);
			$this->add(new atkAttribute("subject", AF_OBLIGATORY | AF_SEARCHABLE),NULL,200);
			$this->add(new atkFileAttribute("attachment", moduleDir("test")."notes_files",  AF_FILE_NO_SELECT  | AF_FILE_PHYSICAL_DELETE),NULL,300);
			$this->add(new atkFckAttribute("note", array("rows"=>6,"cols"=>6),AF_HIDE_LIST,array('ToolbarSet'=>'Basic','Width'=>'450px', 'Height'=>'200px')),NULL,400);
			$this->add(new atkBoolAttribute("email_changes", 0),NULL,500);
			$this->add(new atkDateTimeAttribute("created_date", AF_HIDE_LIST | AF_HIDE_ADD | AF_READONLY),NULL,600);
			$this->add(new atkAttribute("created_by", AF_HIDE_LIST | AF_HIDE_ADD | AF_READONLY),NULL,700);
			$this->add(new atkNumberAttribute("created_by_id", AF_HIDE_LIST | AF_HIDE_ADD | AF_HIDE | AF_READONLY,10,0),NULL,800);
			$modified_date = &$this->add(new atkDateTimeAttribute("modified_date", AF_HIDE_LIST | AF_HIDE_ADD | AF_READONLY),NULL,900);
			$modified_date->setForceUpdate(true); // for field to be updated on database after edit function
			$modified_by = &$this->add(new atkAttribute("modified_by", AF_HIDE_LIST | AF_HIDE_ADD | AF_READONLY),NULL,1000);
			$modified_by->setForceUpdate(true); // for field to be updated on database after edit function
			$this->add(new atkBoolAttribute("active", 0),NULL,1100);
			$this->add(new atkAttribute("event", 0),NULL,1200);
			$this->add(new atkNumberAttribute("event_to_user_id", 0,10,0),NULL,1300);

			//smart search
			$this->setExtendedSearchAction('smartsearch');
			// relations
			

			// index, order and table setups
			$this->setIndex($this->index_field); // set index attribute
			$this->setOrder($this->order_field); // set order attribute(s)
			$this->setTable($this->table); // set node table

		}// end constructor

          function action_admin(&$handler){ 
               global $config_recordsperpage; 
               $config_recordsperpage = 100;
               return $handler->action_admin();
          }
			
          function action_save(&$handler){
                  $attr = &$this->getAttribute($this->primary_field);
                  $attr->removeFlag(AF_PRIMARY);
                  return $handler->action_save();
          }// end function 
			
		function subject_display($record, $mode) 
		{ 
		     $attr = &$this->getAttribute("subject"); 
		     $original = $attr->display($record, $mode); 

		     $pparams[$this->primary_field] = $record[$this->primary_field];  
		     $pparams["atkselector"] = $this->node.".".$this->primary_field."='".$record[$this->primary_field]."'";
		     // link name
			$original = href(dispatch_url($this->module.".".$this->node, "view", $pparams),$original, SESSION_NESTED);
               return $original; 				                       
          }// end function
			
			

          function note_display($record){
               return $record["note"];
          }// end function
               

		// anything here will be processed prior to insetion to database 
		function preAdd(&$record){
		     // $record['created_date'] = date('Y-m-d');
               $this->trackRecord("created", $record); 
		     return true;
		}// end function
			

		// anything here will be processed prior to updating record on db
		function preUpdate(&$record) 
		{ 
		     // $record['modified_date'] = date('Y-m-d'); 
		     $this->trackRecord("modified", $record);
		     return true;
		}// end function
			

          /*
               Jorge Garifuna
               11/16/06
               
               Obtains date, and user info to track record changes

               Assumes existance of attributes: 
                    - created_date {date or datetime}, created_by {int or varchar}, created_by_id {int}
                    - modified_date {date or datetime}, modified_by {int or varchar}, modified_by_id {int}
               
               
               @param $prefix - may be "created" or "modified"
               @param $record - the record to modify
               
               Call example:
                    $this->trackRecord("created", $record); // to track record creation
                    
                    $this->trackRecord("modified", $record); // to track record modification
          */
          function trackRecord($prefix, &$record){ //
               if(empty($prefix)){return false;}
               $a = $this->getAttribute($prefix."_date");               
		     if(is_object($a)){ // check object existance
                    if($a->dbFieldType() == "datetime"){
                         $record[$prefix.'_date'] = $a->datetimeArray(); // datetime field //date('Y-m-d h:i:s');
                    }else if($a->dbFieldType() == "date"){ // date field
		             $record[$prefix.'_date'] = date('Y-m-d');                    
                    }                  
               }
               
               $user = getUser();
               if(empty($user["user_id"])){$user["user_id"]=0;}// if admin, set id to 0

               
               $a = $this->getAttribute($prefix."_by");               
		     if(is_object($a)){
                    if($a->dbFieldType() == "number"){
                        $record[$prefix.'_by'] = $user["user_id"]; 
                    }else if($a->dbFieldType() == "string"){ 
		             $record[$prefix.'_by'] = $user["name"];                     
                    }                  
               }

               $a = $this->getAttribute($prefix."_by_id");               
		     if(is_object($a)){
                    if($a->dbFieldType() == "number"){
                        $record[$prefix.'_by_id'] = $user["user_id"]; 
                    }else if($a->dbFieldType() == "string"){ 
		             $record[$prefix.'_by_id'] = $user["name"];                     
                    }                  
               }         
          }// end function

			
          /* START NODE MESSAGING */
          
          // this function is automatically called after a record has been updated
         function postUpdate($record){                   
               // notify the user that the record has been updated
               $this->printMessage("Record, ".$record[$this->index_field].", Updated Successfully");
               return true;
         }

          // this function is automatically called after a record has been deleted			
         function postDelete($record){                   
               // notify the user that the record has been deleted
               $this->printMessage("Record, ".$record[$this->index_field].", Deleted Successfully");
               return true;
         }

          // this function is automatically called after a record has been added
         function postAdd(&$record){                   
               $this->getMyLastId($record);
               // notify the user that the record has been created
               $this->printMessage("Record, ".$record[$this->index_field].", Created Successfully");
               return true;
         }

          /*
               Jorge Garifuna - info@garidigital.com
               created: 9/12/06
               
               this function obtains the last inserted id of specified table 
          */
          function getMyLastId(&$record){

               $db = &atkGetDb(); 
               // get the id of the last record that was inserted
               $query = "select max(".$this->primary_field.") as last_id from ".$this->table;
               $rows = $db->getrows($query);
               
               if(count($rows)>0){ 
                    $id = $rows[0]["last_id"];
                    $record[$this->primary_field] = $id;
                    $record["atkprimkey"] = $this->node.".".$this->primary_field."='$id'";                                           
               }                       
          }
          /*
               This function is a wrapper to print messages to the top of the screen
               Author: Jorge Garifuna (GariDigital.com) 
               Created Date: 6/27/06

               @param $message               The actual message to be printed
               @param $background_color      The background color of the bar to show message
               @param $text_color            The color of the text to be printed
               
               Note:
               - If your visual creativity is bad like mine, you can find nice colors at the following site:
                    http://www.colorcombos.com/index.html
                    
               - Make sure to include "atkimport("atk.utils.atkmessagequeue");" at the top of your node 
          
          */
          function printMessage($message, $background_color='#6787B0', $text_color='white'){
               atkMessageQueue::addMessage("
".$message."
"); // FFAB35 } /* END NODE MESSAGING */ // initializes values for adding records function initial_values(){ $init_vals = array(); $init_vals["active"] = 1; return $init_vals; }// end function /* What you need to do is create a custom action that can toggle the value. For example: */ function action_active() { $id = $this->m_postvars[$this->primary_field]; $recordset = $this->selectDb($this->table.".".$this->primary_field."=".$id); $record = $recordset[0]; // we only get back one record. // toggle the active value: $record["active"] = abs($record["active"]-1); // Save back the value: $this->updateDb($record); // Go back to the screen where we came from: $this->redirect(); }// end function /* Finally, we have to hook the action somewhere. You can either create a toggle button in the action icons list, by defining a recordActions function, but, if as in your example, you want the value itself to be clickable, you can override its display method, like this: */ function active_display($record, $mode) { $attr = &$this->getAttribute("active"); $original = $attr->display($record, $mode); // now wrap this in a clickable link, and pass the current record $params[$this->primary_field] = $record[$this->primary_field]; return href(dispatch_url($this->module.".".$this->node, "active", $params),$original, SESSION_NESTED); }// end function // obtains the color coded toggle display for subject function rowColor($record){ $color = ""; if($record['active'] ==0){$color = "#FFFBD0";} else if($record['active'] ==1){$color = "";} return $color; }// end rowColor function function descriptor_def(){ return $this->descriptor_field; } // used for header section of list view page function adminHeader(){ // get messages from the queue $msgs = atkMessageQueue::getMessages(); if(count($msgs)>0){$msgs = implode("
", $msgs);} else{$msgs="";} $help_text = $msgs."

Activity Notes

"; return $help_text; }// end function // used for footer section of list view page function adminFooter(){ $help_text = " Notes for the great activities
Author: - Jorge Garifuna (GariDigital.com) <info@GariDigital.com>
Originally Created: - 12/22/06
Updated: - 12/22/06
Version: - 1.0
"; return $help_text; }// end function // this function is called when editing an individual record // any information here will be displayed on the footer section of the edited record page function editPage(&$handler, $record, $locked=false) { return $this->detailPageFooter($handler, $record, $locked); } // this function is called when viewing an individual record // any information here will be displayed on the footer section of the viewed record page function viewPage(&$handler, $record, $locked=false) { return $this->detailPageFooter($handler, $record, $locked,"view"); } // this is a custom helper function for editPage and viewPage // you can consolidate operations here unless you need to display different information // when editing and viewing the record // the information will be displayed on the footer page when editing or viewing an individual record function detailPageFooter(&$handler, $record, $locked=false, $mode="edit") { if($mode == "view"){ $page = $handler->viewPage($record, $locked); }else{// edit $page = $handler->editPage($record, $locked); } $data_info = ""; $page .= $data_info; return $page; } // end function }// end node activity_note