<?php /** * $Id: fileform.inc.php 331 2007-12-23 16:01:11Z malanciault $ * Module: SmartSection * Author: The SmartFactory <www.smartfactory.ca> * Licence: GNU */ if (!defined("XOOPS_ROOT_PATH")) { die("XOOPS root path not defined"); } include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; global $smartsection_file_handler; $fileid = isset($_GET['fileid']) ? intval($_GET['fileid']) : 0; if ($fileid != 0) { $fileObj = new SmartsectionFile($fileid); } else { $fileObj =& $smartsection_file_handler->create(); } // FILES UPLOAD FORM $files_form = new XoopsThemeForm(_MD_SSECTION_UPLOAD_FILE, "form", xoops_getenv('PHP_SELF')); $files_form->setExtra("enctype='multipart/form-data'"); // NAME $name_text = new XoopsFormText(_MD_SSECTION_FILENAME, 'name', 50, 255, $fileObj->name()); $name_text->setDescription(_MD_SSECTION_FILE_NAME_DSC); $files_form->addElement($name_text, true); // DESCRIPTION $description_text = new XoopsFormTextArea(_MD_SSECTION_FILE_DESCRIPTION, 'description', $fileObj->description()); $description_text->setDescription(_MD_SSECTION_FILE_DESCRIPTION_DSC); $files_form->addElement($description_text, 7, 60); // FILE TO UPLOAD
/** * retrieve files from the database * * @param object $criteria {@link CriteriaElement} conditions to be met * @param bool $id_as_key use the fileid as key for the array? * @return array array of {@link SmartsectionFile} objects */ function &getObjects($criteria = null, $id_as_key = false) { $ret = array(); $limit = $start = 0; $sql = 'SELECT * FROM ' . $this->db->prefix('smartsection_files'); if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql .= ' ' . $criteria->renderWhere(); if ($criteria->getSort() != '') { $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); } $limit = $criteria->getLimit(); $start = $criteria->getStart(); } //echo "<br />" . $sql . "<br />"; $result = $this->db->query($sql, $limit, $start); if (!$result) { return $ret; } while ($myrow = $this->db->fetchArray($result)) { $file = new SmartsectionFile(); $file->assignVars($myrow); if (!$id_as_key) { $ret[] =& $file; } else { $ret[$myrow['fileid']] =& $file; } unset($file); } return $ret; }