From: Christopher Kings-L. <ch...@us...> - 2005-05-26 07:30:51
|
Update of /cvsroot/planeshift/SC/natural_resources/php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12504/natural_resources/php Added Files: resources.php Log Message: Editing of natural resources done. Still need to do deletion and creation. --- NEW FILE: resources.php --- <?php /** * resources.php * * This will do all the major stuff for resources * * PHP versions 4 and 5 * * * @category Resources * @package Resources * @author Original Author Chris Kings-Lynne <ch...@fa...> * @copyright 2005-2010 Atomic Blue * @link http://www.planeshift.it * @see * @since File available since Release .1 */ class Resources { var $_link; var $_form; function Resources() { $this->_link = newResourcesConn(); $this->_form = new Form("natural_resources", $this->_link); } function getForm() { return $this->_form; } function seaResources() { // search character function GPH_OutputFile(BASE_DIR . "natural_resources" . DIR_SEP . "css" . DIR_SEP . "seaResource.css", $vars); $myForm = $this->getForm(); $myForm->_action = "searchParse"; $myForm->createSearchForm(); } function searchParse() { $this->seaResources(); $link = $this->_link; $myForm = $this->getForm(); $sqlWhere = $myForm->getSearchResults(); $rs = $link->getResourcesFromSearch($sqlWhere); GPH_OutputFile(BASE_DIR . "natural_resources" . DIR_SEP . "css" . DIR_SEP . "seaResource.css", $vars); $myForm->_editAction = "editRec"; $myForm->showSearchResults($rs); } function editRec() { global $vars; $link = $this->_link; $myForm = $this->_form; $myForm->_ourPage = "natural_resources"; // this will be a custom edit form for each and every page. // set up all our vars etc if (isset($vars['JS_VALIDATOR'])) { foreach ($vars['JS_VALIDATOR'] as $key => $value) { $vars['BAD_FIELD'] .= $value; $failed = true; } } $sqlWhere['fields'][0] = 'id'; $sqlWhere['values'][0] = $vars['id']; $link->getResourceFieldInfo($sqlWhere, $vars); $vars['TAB_WIDTH'] = '111'; $vars['HEADER'] = Form::getTabbedHeader($vars); $vars['HEADER2'] = Form::getTabbedHeader2($vars); $vars['FOOTER'] = Form::getTabbedFooter($vars); $vars['ADD_DBL'] = 'disabled'; $vars['DEL_DBL'] = 'disabled'; $vars['ID_DBL'] = "onFocus='blur();'"; $vars['NAME_DBL'] = "onFocus='blur();'"; $vars['ACTION'] = BASE_URL . "natural_resources/index-natural_resources.php"; $vars['SKILL_SELECT'] = $myForm->createSelectBox("skill", array("skill_id", "name"), "skill_id", array("name"), $vars['skill'], array("name"), "skills"); $vars['ITEM_CAT_ID_SELECT'] = $myForm->createSelectBox("item_cat_id", array("category_id", "name"), "category_id", array("name"), $vars['item_cat_id'], array("name"), "item_categories"); $vars['ITEM_ID_REWARD_SELECT'] = $myForm->customCategorySelectBox("item_id_reward", $vars['item_id_reward'], 'id', array('name'), 'category', " select item_categories.name as category, item_stats.id, item_stats.name from item_categories inner join item_stats on item_categories.category_id=item_stats.category_id order by item_categories.name, item_stats.name"); $myForm->setupFormVars($vars); $vars['LINK1'] = "<img src=\"images/resources1_a.JPG\" width=\"111\" height=\"25\" hspace=\"0\" vspace=\"0\" border=\"0\" alt=\"\" description=\"\">"; // lets print the files we need. This will vary depending on our action, might add this later to a case at class instance GPH_OutputFile(BASE_DIR . "form.js", $vars); GPH_OutputFile(BASE_DIR . "natural_resources" . DIR_SEP . "js" . DIR_SEP . "editResource.js", $vars); GPH_OutputFile(BASE_DIR . "natural_resources" . DIR_SEP . "css" . DIR_SEP . "editResource.css", $vars); GPH_OutputFile(BASE_DIR . "natural_resources" . DIR_SEP . "html" . DIR_SEP . "editResource.html", $vars); echo $vars['BAD_FIELD']; } function updRec() { // update our records global $vars; $link = $this->_link; $myForm = $this->_form; $myForm->validateFormsVals(&$vars); $failed = false; if (isset($vars['JS_VALIDATOR'])) { foreach ($vars['JS_VALIDATOR'] as $key => $value) { $vars['BAD_FIELD'] .= $key; $failed = true; } } if($failed) { $vars['ERROR'] = "Update failed due to blank fields or bad data. Problematic fields are highlighted in yellow."; $vars['ERROR_TYPE'] = 'error'; $this->editRec(); } else { $vars['ERROR'] = "Update Successful!"; $vars['ERROR_TYPE'] = 'message'; $link->updResource($vars, "id"); $vars = array(); $this->seaResources(); } } } ?> |