table = "content"; $this->nonListFields['text_html'] = 1; $this->nonListFields['arrange_order'] = 1; $this->nonListFields['created_by'] = 1; $this->nonListFields['created_on'] = 1; $this->nonListFields['last_modified_by'] = 1; $this->nonListFields['last_modified_on'] = 1; $this->altNames['name'] = 'Title'; $this->altNames['sectionid'] = 'Section'; $this->altNames['description'] = 'Description'; $this->altNames['arrange_order'] = 'Order'; $this->altNames['text_html'] = "HTML Content"; $this->altNames['created_by'] = 'Created By'; $this->altNames['created_on'] = 'Created On'; $this->altNames['last_modified_by'] = 'Last Modified By'; $this->altNames['last_modified_on'] = 'Last Modified On'; // dont enable search for this component $this->showSearch = 1; ////////////// End Config ///////////////////////////////////////////////// SiteAdmin::SiteAdmin(); } function displayFieldarrange_order($field, $item) { $fieldName = $field['Field']; $options = array(); $optionNames = array(); if(!empty($item) || sizeof($item) >= 1) { $q = 'SELECT COUNT(*) AS n FROM '.$this->table.' WHERE sectionid='.$item['sectionid']; $rs = mysql_query($q); $row = mysql_fetch_array($rs); $count = $row['n']; for($i = 1; $i <= ($count - 1); $i++) $options[] = $optionNames[] = $i; $options[] = $count; $optionNames[] = 'End'; } else { $options[] = -1; $optionNames[] = 'End'; } $fieldValue = empty($item) ? -1 : $item['arrange_order']; $this->displayDropList($fieldName, $options, $optionNames, $fieldValue); } function handleFieldarrange_order($field, $formValue) { global $mode; $q = 'SELECT COUNT(*) AS n FROM '.$this->table.' WHERE sectionid='.$this->query['sectionid']; $rs = mysql_query($q); $row = mysql_fetch_array($rs); $count = $row['n']; if($mode == "insert") { return ++$count; } else { if($formValue > $count) { $formValue = $count; } $q = 'SELECT arrange_order FROM '.$this->table.' WHERE id='.$this->query['id']; $rs = mysql_query($q); $row = mysql_fetch_array($rs); $currentao = $row['arrange_order']; if($currentao < $formValue) { $q = 'UPDATE '.$this->table.' SET arrange_order=arrange_order-1 '. 'WHERE arrange_order > '.$currentao.' AND arrange_order <= '.$formValue; mysql_query($q); } else { $q = 'UPDATE '.$this->table.' SET arrange_order=arrange_order+1 '. 'WHERE arrange_order < '.$currentao.' AND arrange_order >= '.$formValue; mysql_query($q); } return $formValue; } } function displayFieldcreated_by($field, $item) { global $mode; if($mode == 'add') { $this->displayHiddenField($field['Field'], $user['id']); $this->displayTextStatic($field['Field'], $user['name']); } else { $sql = 'SELECT name FROM adminusers WHERE id='.$item[$field['Field']]; $rs = mysql_query($sql); $author = mysql_fetch_array($rs); $this->displayHiddenField($field['Field'], $item[$field['Field']]); $this->displayTextStatic($field['Field'], "".$author['name'].""); } } /* function handleFieldcreated_by($field, $item) { global $mode; if($mode == 'insert') { return $this->user['id']; } else { return $item; } } */ function displayFieldcreated_on($field, $item) { global $mode; // we don't want to display this field for editing. render it as static text. // we will handle this in $this->handleFieldlast_modified if($mode == 'insert') { $this->displayHiddenField($field['Field'], date("Y-m-d H:i")); $this->displayTextStatic($field['Field'], date("Y-m-d H:i")); } else { $this->displayHiddenField($field['Field'], $item[$field['Field']]); $this->displayTextStatic($field['Field'], $item[$field['Field']]); } } function handleFieldcreated_on($field, $formValue) { if($mode == 'insert') { return 'NOW()'; } else { return "'".$formValue."'"; } } function displayFieldlast_modified_by($field, $item) { global $mode; if($mode == 'add') { $this->displayHiddenField($field['Field'], $user['id']); $this->displayTextStatic($field['Field'], $user['name']); } else { $sql = 'SELECT name FROM adminusers WHERE id='.$item[$field['Field']]; $rs = mysql_query($sql); $author = mysql_fetch_array($rs); $this->displayHiddenField($field['Field'], $item[$field['Field']]); $this->displayTextStatic($field['Field'], "".$author['name'].""); } } /* function handleFieldlast_modified_by($field, $item) { global $mode; if($mode == 'insert') { return $this->user['id']; } else { return $item; } } */ function displayFieldlast_modified_on($field, $item) { global $mode; // we don't want to display this field for editing. render it as static text. // we will handle this in $this->handleFieldlast_modified if($mode == 'edit') { $this->displayTextStatic($field['Field'], $item[$field['Field']]); } $this->displayHiddenField($field['Field'], $item[$field['Field']]); } function handleFieldlast_modified_on($field, $item) { // everytime we go to modify a record in this table, we will simple set // this field to NOW() in order to reflect when it was last changed. return 'NOW()'; } } $aObject= new Content(); $aObject->proccess_query(); ?>