| // +---------------------------------------------------------------------------+ /** * Simple wrapper to MediaDAO to use with AJAX. * * @package Media * @author Julien Casanova */ require_once SGL_MOD_DIR . '/media/classes/MediaDAO.php'; require_once SGL_CORE_DIR . '/Delegator.php'; require_once 'HTML/Template/Flexy.php'; class MediaAjaxProvider extends SGL_Manager { /** * */ function MediaAjaxProvider() { SGL::logMessage(null, PEAR_LOG_DEBUG); parent::SGL_Manager(); $this->da = & MediaDAO::singleton(); } function &singleton() { static $instance; // If the instance is not there, create one if (!isset($instance)) { $class = __CLASS__; $instance = new $class(); } return $instance; } function getValidIds($options) { return $this->da->getValidIds($options); } function getMediaFiles($options) { SGL::logMessage(null, PEAR_LOG_DEBUG); $output = & new SGL_Output(); $output->theme = "default"; $output->webRoot = $this->conf['site']['baseUrl']; $output->moduleName = "media"; $output->aMedia = $this->da->getMediaFiles($options); $additions = array(); if ($options['viewType'] == 'thumb') { $output->masterTemplate = 'mediaList_viewThumb.html'; } else { $output->masterTemplate = 'mediaList_viewList.html'; } $templ = & new SGL_HtmlSimpleView($output); $additions[] = $templ->render(); return $additions; } function deleteMediaById($mediaId) { $ok = $this->da->deleteMediaById($mediaId); $ret = (!is_a($ok, 'PEAR_Error')) ? array('messageType' => 'info', 'message' => 'Media deleted successfully') : array('messageType' => 'error', 'message' => 'Sorry, couldn\'t delete this media'); return $ret; } } ?>