protected function initSideBar() { $this->sidebar = new SiteSidebar(); $gadget_instances = false; if (isset($this->app->memcache)) { $gadget_instances = $this->app->memcache->get('gadget_instances'); } if ($gadget_instances === false) { $sql = sprintf('select * from GadgetInstance where instance %s %s order by displayorder', SwatDB::equalityOperator($this->app->getInstanceId()), $this->app->db->quote($this->app->getInstanceId(), 'integer')); $gadget_instances = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('SiteGadgetInstanceWrapper')); $gadget_instances->loadAllSubRecordsets('setting_values', SwatDBClassMap::get('SiteGadgetInstanceSettingValueWrapper'), 'GadgetInstanceSettingValue', 'gadget_instance'); if (isset($this->app->memcache)) { $this->app->memcache->set('gadget_instances', $gadget_instances); } } else { $gadget_instances->setDatabase($this->app->db); } foreach ($gadget_instances as $gadget_instance) { $gadget = SiteGadgetFactory::get($this->app, $gadget_instance); $this->sidebar->add($gadget); } $this->sidebar->init(); }
} // }}} // {{{ public static function getAuthorRelativeUri() public static function getAuthorRelativeUri(SiteApplication $app, BlorgAuthor $author) { $path = $app->config->blorg->path . 'author'; return $path . '/' . $author->shortname; } // }}} // {{{ public static function getCommentRelativeUri() public static function getCommentRelativeUri(SiteApplication $app, SiteComment $comment) { return Blorg::getPostRelativeUri($app, $comment->post) . '#comment' . $comment->id; } // }}} // {{{ private function __construct() /** * Prevent instantiation of this static class */ private function __construct() { } } Blorg::setupGettext(); SwatUI::mapClassPrefixToPath('Blorg', 'Blorg'); SiteViewFactory::addPath('Blorg/views'); SiteViewFactory::registerView('post', 'BlorgPostView'); SiteViewFactory::registerView('post-comment', 'BlorgCommentView'); SiteViewFactory::registerView('author', 'BlorgAuthorView'); SiteGadgetFactory::addPath('Blorg/gadgets');
protected function initUri($source) { $map = self::$uri_map; $gadgets = SiteGadgetFactory::getAvailable($this->app); foreach ($gadgets as $gadget) { $map = array_merge($map, $gadget->ajax_proxy_map); } foreach ($map as $from => $to) { // escape delimiters $pattern = str_replace('@', '\\@', $from); $regexp = '@' . $pattern . '@u'; if (preg_match($regexp, $source) === 1) { // replace matches in to string $this->uri = preg_replace($regexp, $to, $source); break; } } if ($this->uri === null) { throw new SiteNotFoundException('Page not found.'); } }
* If $config->pinhole->ad_referers_only is true, the referer's domain is * checked against the site's domain to ensure the page has been arrived at * via another site. * * @param SiteApplication $app The current application * @param string $ad_type The type of ad to display */ public static function displayAd(SiteApplication $app, $type) { $type_name = 'ad_' . $type; if ($app->config->pinhole->{$type_name} != '') { $base_href = $app->getBaseHref(); $referer = SiteApplication::initVar('HTTP_REFERER', null, SiteApplication::VAR_SERVER); // Display ad if referers only is off OR if there is a referer and // it does not start with the app base href. if (!$app->config->pinhole->ad_referers_only || $referer !== null && strncmp($referer, $base_href, strlen($base_href)) != 0) { echo '<div class="ad">'; echo $app->config->pinhole->{$type_name}; echo '</div>'; } } } } Pinhole::setupGettext(); // require here to prevent "Class __PHP_Incomplete_Class has no unserializer" errors require_once 'Pinhole/dataobjects/PinholeAdminUser.php'; SwatDBClassMap::addPath(dirname(__FILE__) . '/dataobjects'); SwatDBClassMap::add('AdminUser', 'PinholeAdminUser'); SiteGadgetFactory::addPath('Pinhole/gadgets'); SiteViewFactory::addPath('Pinhole/views'); SiteViewFactory::registerView('photo-comment', 'PinholeCommentView');