public function actionFeed() { $req = new CHttpRequest(); // retrieve the latest posts $posts = Post::model()->findAll(array('order' => 'create_time DESC', 'limit' => Yii::app()->params['postsPerFeedCount'])); // convert to the format needed by Zend_Feed $entries = array(); foreach ($posts as $post) { $entries[] = array('title' => CHtml::encode($post->title), 'link' => CHtml::encode($req->getHostInfo() . $post->url), 'description' => $post->content, 'lastUpdate' => $post->create_time); } // generate and render RSS feed $feed = Zend_Feed::importArray(array('title' => 'My Post Feed', 'link' => $this->createUrl(''), 'charset' => 'UTF-8', 'entries' => $entries), 'rss'); $feed->send(); }
/** * Parses a URL based on this rule. * @param CUrlManager $manager the URL manager * @param CHttpRequest $request the request object * @param string $pathInfo path info part of the URL * @param string $rawPathInfo path info that contains the potential URL suffix * @return mixed the route that consists of the controller ID and action ID or false on error */ public function parseUrl($manager, $request, $pathInfo, $rawPathInfo) { if ($this->verb !== null && !in_array($request->getRequestType(), $this->verb, true)) { return false; } if ($manager->caseSensitive && $this->caseSensitive === null || $this->caseSensitive) { $case = ''; } else { $case = 'i'; } if ($this->urlSuffix !== null) { $pathInfo = $manager->removeUrlSuffix($rawPathInfo, $this->urlSuffix); } // URL suffix required, but not found in the requested URL if ($manager->useStrictParsing && $pathInfo === $rawPathInfo) { $urlSuffix = $this->urlSuffix === null ? $manager->urlSuffix : $this->urlSuffix; if ($urlSuffix != '' && $urlSuffix !== '/') { return false; } } if ($this->hasHostInfo) { $pathInfo = strtolower($request->getHostInfo()) . rtrim('/' . $pathInfo, '/'); } $pathInfo .= '/'; if (preg_match($this->pattern . $case, $pathInfo, $matches)) { foreach ($this->defaultParams as $name => $value) { if (!isset($_GET[$name])) { $_REQUEST[$name] = $_GET[$name] = $value; } } $tr = array(); foreach ($matches as $key => $value) { if (isset($this->references[$key])) { $tr[$this->references[$key]] = $value; } elseif (isset($this->params[$key])) { $_REQUEST[$key] = $_GET[$key] = $value; } } if ($pathInfo !== $matches[0]) { // there're additional GET params $manager->parsePathInfo(ltrim(substr($pathInfo, strlen($matches[0])), '/')); } if ($this->routePattern !== null) { return strtr($this->route, $tr); } else { return $this->route; } } else { return false; } }
// uncomment the following to define a path alias // Yii::setPathOfAlias('local','path/to/local-folder'); // This is the main Web application configuration. Any writable // CWebApplication properties can be configured here. $modules = array(); $envFile = dirname(__FILE__) . '/../../sites/env/config.' . REQUESTED_HOST . '.php'; if (file_exists($envFile)) { include $envFile; $moduleConfigFile = dirname(__FILE__) . '/../../sites/' . SITE_DIR . '/protected/runtime/cache/modules.php'; if (file_exists($moduleConfigFile)) { $modules = (include $moduleConfigFile); } } $config = array('basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..', 'name' => 'Indition Diagnostic Tool', 'defaultController' => 'Diagnostic/default', 'preload' => array('log', 'errorHandler', 'Xpress'), 'import' => array('application.models.*', 'application.components.*', 'application.modules.Xpress.extensions.web.widgets.*', 'application.modules.Xpress.extensions.web.*', 'application.modules.Xpress.components.*'), 'modules' => array_merge(array('Xpress', 'Diagnostic'), $modules), 'components' => array('XService' => array('class' => 'Xpress.components.XService'), 'user' => array('class' => 'CWebUser', 'allowAutoLogin' => true), 'errorHandler' => array('class' => 'Xpress.components.XErrorHandler', 'errorAction' => 'site/error'), 'clientScript' => array('packages' => array('jquery' => array('js' => array(YII_DEBUG ? 'jquery-2.1.3.js' : 'jquery-2.1.3.min.js'), 'basePath' => 'application.modules.Xpress.assets.scripts.jquery'))), 'log' => array('class' => 'CLogRouter', 'routes' => array(array('class' => 'CFileLogRoute', 'levels' => 'error, warning')))), 'params' => array('adminEmail' => '*****@*****.**')); $request = new CHttpRequest(); $hostInfo = parse_url($request->getHostInfo(), PHP_URL_HOST); // top level domain element $tldElements = array_slice(explode('.', $hostInfo), -2); // support single login to manage different sub domain $domain = '.' . implode('.', $tldElements); $GLOBALS['TLD'] = $domain; // environment file locates in /sites/env folder using this naming convention: config.domain.php $envFile = 'config.' . $hostInfo . '.php'; $envFile = dirname(__FILE__) . '/../../sites/env/' . $envFile; if (file_exists($envFile)) { include $envFile; //$config['preload'][] = 'XService'; $config['components']['authManager'] = array('class' => 'Xpress.extensions.web.auth.XAuthManager', 'assignmentTable' => SITE_ID . '_authassignment', 'itemTable' => SITE_ID . '_authitem', 'itemChildTable' => SITE_ID . '_authitemchild'); // database if (count($dbs)) { foreach ($dbs as $key => $dbConfig) {