* @package ISM3 * */ class BlogFrontHomeLatestPlugin extends Site { public $site; // Website session class reference, populated when the plugin is called by the Website public $ism; // ISM3 session class reference, populated when the plugin is called by ISM3 // This is an array of template names required by this plugin. In most cases, // there will be just one template. public $templates = array('blog.front.home.latest.tpl'); // Name of the module owning this plug-in private $_parent_module = 'blog'; // Name of the owner module's primary data access class private $_parent_classname = 'ISMModuleBlog'; // Multidimensional array of configuration directives set in getconfformtablearray(). private $_configuration = array(); // When in configuration mode, this will be a pointer to the owner module's data access class private $_module; // For configuration mode /** * function __construct * * The Site and ISM variables cannot set simultaneously. If the plugin is loaded in ISM3, the * ISM variable is populated. If the plugin is loaded by the website, the Site variable is populated. * * CALLED BY BOTH ISM3 AND THE WEBSITE * * @param &$site Site Website session class reference * @param $conf Array Configuration directives for this plugin * @param &$ism ISM ISM3 session class reference * */ public function __construct(&$site, $conf, &$ism = '') { $this->site = $site; if (!is_array($conf)) { $conf = array(); } $this->_configuration = $conf; if (!empty($ism)) { // Configuration mode $this->ism = $ism; require_once('modules/'.$this->_parent_module.'/common.inc.php'); eval('$this->_module = new '.$this->_parent_classname.'($this->ism);'); } // We're all ready return true; } /** * function run * * CALLED BY THE WEBSITE * * @param $width Integer Size of constraining div tag (provided by layout file) * */ public function run($width) { if (!empty($this->_configuration['posters']) && is_array($this->_configuration['posters'])) { // Create instance of Smarty template engine $sm = $this->site->smarty(); // The number of blog posts to display, loaded from the configuration array $entrylimit = $this->_configuration['num']; // This will hold all of the blog links $entries = array(); // Get entries $sql = "SELECT b.*, t.text AS title, a.alias AS poster, ". " date_format(b.date, '".$this->site->config['date_format']."') AS date_formatted ". " FROM `blog` b, ISM3.users u, `blog_aliases` a, `std_core_text` t ". " WHERE ". " b.is_hidden='0' AND a.user_id=b.user_id AND ". " u.id=a.user_id AND ". " b.date_configuration['posters']).") AND ". " t.module_id='blog' AND t.name='title' AND t.linked_id=b.id AND t.language='".$this->site->language."' ". " ORDER BY b.is_sticky DESC, b.date DESC LIMIT 0, $entrylimit "; $entry_query = $this->site->sdb_query($sql); while ($entry = $this->site->sdb_fetch_array($entry_query)) { $entry['xml'] = parent::xml_readandparse('blog/blogentry_'.$entry['id'].'.xml', 'Blogentry', 1); $entry['readmore'] = $this->site->path_http.$this->site->pages[$this->_configuration['rdpage']]['path'].'index.html?entry_id='.$entry['id']; array_push($entries, $entry); } $sm->assign('entries', $entries); $sm->display($this->templates[0]); } // If no authors are set to display, lets throw an error else { $this->site->error('No blog authors have been selected to display.'); } } /** * function getconfformtablearray * * CALLED BY ISM3 * * This function returns an array that is compatible with the ISMHTMLFormTable class. This * class encapsulates many basic HTML GUI techniques and allows developers to efficiently * create data tables and form input tables. * */ public function getconfformtablearray() { // We need the StdSiteBuilder module to get the list of possible page names that the blog // cound reside on. $sb = new ISMModuleStdSiteBuilder($this->ism); $rows = array( // Configuration directive 1; 1 row of the FormTable array( array( 'type' => 'field', 'value' => 'Blogs to display:' ), array( 'type' => 'checkboxarray', 'values' => $this->_module->getpostershash(), 'selected_ar' => ((!empty($this->_configuration['posters'])) ? $this->_configuration['posters'] : ''), 'name' => 'plugin_posters' ) ), // Configuration directive 2; 1 row of the FormTable array( array( 'type' => 'field', 'value' => 'Number of blog posts to display to link:' ), array( 'type' => 'text', 'size' => 5, 'value' => ((!empty($this->_configuration['num'])) ? $this->_configuration['num'] : '3'), 'name' => 'plugin_num' ) ), // Configuration directive 3; 1 row of the FormTable array( array( 'type' => 'field', 'value' => 'Page containing Blog:' ), array( 'type' => 'select', 'values' => array('' => '') + $sb->getpageshash(), 'selected' => ((!empty($this->_configuration['rdpage'])) ? $this->_configuration['rdpage'] : ''), 'name' => 'plugin_rdpage') ), ); return $rows; } }