| // +---------------------------------------------------------------------------+ // $Id$ /** * Helper methods for publisher module. * * @package publisher * @author Demian Turner */ class PublisherBase { /** * Toggles the queryRange string. * * a collection can represent the contents from the entire db for * a given type, or only the results specific to the current category * * @access public * @param string either 'all' or 'thisCategory' * @return string html to construct the queryRange toggle */ function getQueryRange($input) { SGL::logMessage(null, PEAR_LOG_DEBUG); $sessionInfo = (SID) ? SID : ''; if (!empty($sessionInfo)) { $sessionInfo = '&' . $sessionInfo; } if ($input->queryRange == 'all') { $html = "" . SGL_String::translate('whole DB') . ""; } else { $html = "" . SGL_String::translate('this category') . ""; } return $html; } /** * Propagates certain values in the session. * * currently only currentCatId, currentResRange * and dataTypeId (article template type) * * @access public * @param object $input processed $input from validate() * @return void */ function maintainState(& $input) { SGL::logMessage(null, PEAR_LOG_DEBUG); // look for catID $sessCatID = SGL_Session::get('currentCatId'); if (!$input->catID && !$sessCatID) { // if not in input or session, default to 1 $input->catID = 1; } elseif (!$input->catID) // if not in input, grab from session $input->catID = SGL_Session::get('currentCatId'); // add to session SGL_Session::set('currentCatId', $input->catID); // look for resource range, ie: 'all' or 'thisCategory' $sessResourceRange = SGL_Session::get('currentResRange'); if (!isset($input->queryRange) && !$sessResourceRange) { // if not in input or session, default to 'all' $input->queryRange = 'all'; } elseif (!isset($input->queryRange)) // if not in input, grab from session $input->queryRange = SGL_Session::get('currentResRange'); // add to session SGL_Session::set('currentResRange', $input->queryRange); // look for dataTypeID for template selection in article manager $sessDatatypeID = SGL_Session::get('dataTypeId'); // if not in input or session, set default article type if (!isset($input->dataTypeID) && !$sessDatatypeID) { $c = &SGL_Config::singleton(); $conf = $c->getAll(); $defaultArticleType = (array_key_exists('defaultArticleViewType', $conf['site'])) ? $conf['site']['defaultArticleViewType'] : 1; $input->dataTypeID = $defaultArticleType; // if not in input, grab from session } elseif (!isset($input->dataTypeID)) $input->dataTypeID = SGL_Session::get('dataTypeId'); // add to session SGL_Session::set('dataTypeId', $input->dataTypeID); } function getDocumentListByCatID($catID) { SGL::logMessage(null, PEAR_LOG_DEBUG); require_once 'DB/DataObject.php'; $c = &SGL_Config::singleton(); $conf = $c->getAll(); $documentList = DB_DataObject::factory($conf['table']['document']); $documentList->category_id = $catID; $result = $documentList->find(); $documents = array(); if ($result > 0) { while ($documentList->fetch()) { $documents[] = clone($documentList); } } return $documents; } } ?>