AAAAindex.html000066600000000035151453225620006550 0ustar00 .htaccess000066600000000177151453225620006360 0ustar00 Order allow,deny Deny from all db_record_loader.ctp000066600000017757151453225620010557 0ustar00
DB Record Loader
Header(array('basic' => 'Basic', 'advanced' => 'Advanced', 'help' => 'Help'), 'db_record_loader_config_{n}'); ?> tabStart('basic'); ?> input('action_db_record_loader_{n}_dbfield_config', array('type' => 'text', 'label' => "DB Field", 'class' => 'medium_input', 'value' => '', 'smalldesc' => "The field name which will be used to query the table record.")); ?> getTableList(); $options = array(); foreach($tables as $table){ $options[$table] = $table; } ?> input('action_db_record_loader_{n}_table_name_config', array('type' => 'select', 'label' => 'Table', 'options' => $options, 'empty' => " - ", 'class' => 'medium_input', 'smalldesc' => "The table name to load the data from.")); ?> input('action_db_record_loader_{n}_request_param_config', array('type' => 'text', 'label' => "Request Param", 'class' => 'medium_input', 'value' => '', 'smalldesc' => "The param name which will exist in the request url to the form, its value will be used to load the target db record, if the value of this parameter is an array then the array values will be used inside 'IN' statement.")); ?> input('action_db_record_loader_{n}_load_fields_config', array('type' => 'select', 'label' => 'Load Fields', 'options' => array(0 => 'No', 1 => 'Yes'), 'class' => 'medium_input', 'smalldesc' => "Should any form fields be loaded with data ? your field name should match the table's column name.")); ?> input('action_db_record_loader_{n}_curly_replacer_config', array('type' => 'select', 'label' => 'Curly Replacer', 'options' => array(0 => 'No', 1 => 'Yes'), 'class' => 'medium_input', 'smalldesc' => "Should curly brackets fields names be replaced with data from the form data array ?")); ?> input('action_db_record_loader_{n}_model_id_config', array('type' => 'text', 'label' => "Model ID", 'class' => 'medium_input', 'value' => '', 'smalldesc' => "The key under which the loaded record data will be stored in the form->data array.")); ?> input('action_db_record_loader_{n}_load_under_modelid_config', array('type' => 'select', 'label' => 'Load Under Model ID', 'options' => array(0 => 'No', 1 => 'Yes'), 'class' => 'medium_input', 'smalldesc' => "Should the data get loaded under the model id inside the data array ? this will affect your form fields names, if this is set to yes then your fields names should be in this format : name='MODEL_ID[field_name]'
and your curly brackets strings: {MODEL_ID.field_name}")); ?> tabEnd(); ?> tabStart('advanced'); ?> input('action_db_record_loader_{n}_content1_config', array('type' => 'textarea', 'label' => 'WHERE statement', 'rows' => 10, 'cols' => 50, 'smalldesc' => "The code used for the WHERE statement, some notes:
1 - leave empty to use the default request param with column name formula OR use it to load whatever record you need.
2 - don't use the WHERE word.
3 - You can use PHP code with tags. ")); ?> input('action_db_record_loader_{n}_array_fields_sets_config', array('type' => 'text', 'label' => "Array Fields Sets", 'class' => 'medium_input', 'value' => '', 'smalldesc' => "list of fields of types array stored in the table, fields values will be extracted, you can use single or multiple sets, e.g:
field1,field2 OR field1,field2-field3,field4.")); ?> input('action_db_record_loader_{n}_array_separators_config', array('type' => 'text', 'label' => "Array Separators", 'class' => 'medium_input', 'value' => '', 'smalldesc' => "The separators used to explode the array fields values, multiple sets supported, should match the number of sets for the array fields.")); ?> input('action_db_record_loader_{n}_params_fields_config', array('type' => 'text', 'label' => "Parameters fields", 'class' => 'medium_input', 'value' => '', 'smalldesc' => "Comma separated list of fields which will be in Joomla params fields format, values will be extracted to an array.")); ?> tabEnd(); ?> tabStart('help'); ?>

tabEnd(); ?>
db_record_loader.php000066600000011254151453225620010542 0ustar00 0, 'notfound' => 0, 'nodata' => 0); var $group = array('id' => 'data_operations', 'title' => 'Data/DB Operations'); var $details = array('title' => 'DB Record Loader', 'tooltip' => 'Load 1 record from a Database table based on a request parameter value or a custom DB query.'); function run($form, $actiondata){ $params = new JParameter($actiondata->params); $table_name = $params->get('table_name', ''); $static_where = ""; if(!empty($table_name) && (trim($params->get('dbfield', '')) || trim($actiondata->content1))){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); $req_param = $form->get_array_value($form->data, explode('.', $params->get('request_param', ''))); if(is_null($req_param)){ $req_param = ''; }else{ $static_where = "`".$params->get('dbfield', '')."` = '".$form->escapeVar($req_param)."'"; if(is_array($req_param) && !empty($req_param)){ $static_where = "`".$params->get('dbfield', '')."` IN ('".implode("','", $form->escapeVar($req_param))."')"; } } $where = trim($actiondata->content1) ? $this->_processWhere(trim($actiondata->content1), $form) : $static_where; //load the model_id $model_id_sub = preg_replace('/(?:^|_)(.?)/e', "strtoupper('$1')", $table_name); $model_id = $params->get('model_id', ''); if(empty($model_id)){ $model_id = $model_id_sub; } //add a copy of the qury to the debug $form->debug['db_record_loader'][] = "SELECT * FROM `".$table_name."` AS `".$model_id."` WHERE ".$where; //run the query $database->setQuery("SELECT * FROM `".$table_name."` AS `".$model_id."` WHERE ".$where); $data = $database->loadAssoc(); if(!is_array($data)){ $data = array(); } //check array fields if(trim($params->get('array_fields_sets', '')) && trim($params->get('array_separators', ''))){ $fields_sets = explode('-', trim($params->get('array_fields_sets', ''))); $separators = explode('-', trim($params->get('array_separators', ''))); foreach($fields_sets as $k1 => $fields_set){ $fields_list = explode(',', $fields_set); foreach($fields_list as $k2 => $field){ if(isset($data[$field])){ $data[$field] = explode($separators[$k1], $data[$field]); } } } } //process any params fields if(strlen(trim($params->get('params_fields', ''))) > 0){ $params_fields = explode(",", trim($params->get('params_fields', ''))); foreach($params_fields as $params_field){ if(isset($data[$params_field]) && !empty($data[$params_field])){ $local_params = new JParameter($data[$params_field]); $data[$params_field] = $local_params->toArray(); } } } if((int)$params->get('load_under_modelid', 1) == 1){ $form->data[$model_id] = $data; }else{ $form->data = array_merge($form->data, $data); } //check the result $request_val = $req_param;//JRequest::getVar($params->get('request_param', '')); if(!empty($data)){ $this->events['found'] = 1; }else if(empty($request_val)){ $this->events['nodata'] = 1; }else if(empty($data)){ $this->events['notfound'] = 1; }else{ }/*else{ $this->events['found'] = 1; }*/ //replace all the curly brackets strings /*if(isset($form->form_details->content)){ if((int)$params->get('curly_replacer', 1)){ $form->form_details->content = $form->curly_replacer($form->form_details->content, $form->data); } //load any form fields if this setting is enabled if((int)$params->get('load_fields', 1)){ include_once(JPATH_SITE.DS.'components'.DS.'com_chronoforms'.DS.'libraries'.DS.'includes'.DS.'data_republish.php'); $HTMLFormPostDataLoad = new HTMLFormPostDataLoad(); $form->form_details->content = $HTMLFormPostDataLoad->load($form->form_details->content, $form->data); } }*/ } } function _processWhere($code, $form){ ob_start(); eval("?>".$code); $code = ob_get_clean(); return $code; } function load($clear){ if($clear){ $action_params = array( 'dbfield' => '', 'table_name' => '', 'request_param' => '', 'load_fields' => 1, 'curly_replacer' => 1, 'model_id' => '', 'array_fields_sets' => '', 'array_separators' => '', 'params_fields' => '', 'load_under_modelid' => '', 'content1' => '' ); } return array('action_params' => $action_params); } } ?>