⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 controller.php

📁 一款可以和GOOGLE媲美的开源统计系统,运用AJAX.功能强大. 无色提示:按照需要PHP5.1以上和MySQL数据库支持。
💻 PHP
字号:
<?php/** * Piwik - Open source web analytics *  * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later * @version $Id: Controller.php 241 2008-01-26 01:30:37Z matt $ *  * @package Piwik_CoreHome *  */require_once "API/Request.php";require_once "ViewDataTable.php";/** * @package Piwik_Dashboard */class Piwik_Dashboard_Controller extends Piwik_Controller{	function getListWidgets()	{		$widgets = Piwik_GetWidgetsList();		$json = json_encode($widgets);		return $json;	}		public function embeddedIndex()	{				$view = new Piwik_View('Dashboard/templates/index.tpl');		$this->setGeneralVariablesView($view);		$view->layout = $this->getLayout();		$view->availableWidgets = $this->getListWidgets();		echo $view->render();	}	public function index()	{		//add the header for stand-alone mode		$view = new Piwik_View('Dashboard/templates/header.tpl');		echo $view->render();		$this->embeddedIndex();	}		/**	 * Records the layout in the DB for the given user.	 *	 * @param string $login	 * @param int $idDashboard	 * @param string $layout	 */	protected function saveLayoutForUser( $login, $idDashboard, $layout)	{		$paramsBind = array($login, $idDashboard, $layout, $layout);		Piwik_Query('INSERT INTO '.Piwik::prefixTable('user_dashboard') .					' (login, iddashboard, layout)						VALUES (?,?,?)					ON DUPLICATE KEY UPDATE layout=?',					$paramsBind);	}		/**	 * Returns the layout in the DB for the given user, or false if the layout has not been set yet.	 * Parameters must be checked BEFORE this function call	 *	 * @param string $login	 * @param int $idDashboard	 * @param string|false $layout	 */	protected function getLayoutForUser( $login, $idDashboard)	{		$paramsBind = array($login, $idDashboard);		$return = Piwik_FetchAll('SELECT layout FROM '.Piwik::prefixTable('user_dashboard') .					' WHERE login = ? AND iddashboard = ?', $paramsBind);		if(count($return) == 0)		{			return false;		}		return $return[0]['layout'];	}		/**	 * Saves the layout for the current user	 * anonymous = in the session	 * authenticated user = in the DB	 */	public function saveLayout()	{		$layout = Piwik_Common::getRequestVar('layout');		$idDashboard = Piwik_Common::getRequestVar('idDashboard', 1, 'int' );		$currentUser = Piwik::getCurrentUserLogin();		if($currentUser == 'anonymous')		{			$_SESSION['layout'][$idDashboard] = $layout;		}		else		{			$this->saveLayoutForUser($currentUser,$idDashboard, $layout);		}	}		/**	 * Get the dashboard layout for the current user (anonymous or loggued user) 	 *	 * @return string $layout	 */	protected function getLayout()	{		$idDashboard = Piwik_Common::getRequestVar('idDashboard', 1, 'int' );		$currentUser = Piwik::getCurrentUserLogin();		if($currentUser == 'anonymous')		{			if(!isset($_SESSION['layout'][$idDashboard]))			{				return false;			}			return $_SESSION['layout'][$idDashboard];		}		else		{			return $this->getLayoutForUser($currentUser,$idDashboard);		}			}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -