添加 Piwik 到代码库中。
+YUCHENG HU+ git-svn-id: https://svn.code.sf.net/p/hawebs/svn@478 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
<?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: FormDatabaseSetup.php 2167 2010-05-12 05:12:45Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_Installation
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_Installation
|
||||
*/
|
||||
class Piwik_Installation_FormDatabaseSetup extends Piwik_Form
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct($action = '', $attributes = 'autocomplete="off"');
|
||||
}
|
||||
function init()
|
||||
{
|
||||
$availableAdapters = Piwik_Db_Adapter::getAdapters();
|
||||
$adapters = array();
|
||||
foreach($availableAdapters as $adapter => $port)
|
||||
{
|
||||
$adapters[$adapter] = $adapter;
|
||||
}
|
||||
|
||||
$formElements = array(
|
||||
array('text', 'host', Piwik_Translate('Installation_DatabaseSetupServer'), 'value='.'localhost'),
|
||||
array('text', 'username', Piwik_Translate('Installation_DatabaseSetupLogin')),
|
||||
array('password', 'password', Piwik_Translate('Installation_DatabaseSetupPassword')),
|
||||
array('text', 'dbname', Piwik_Translate('Installation_DatabaseSetupDatabaseName')),
|
||||
array('text', 'tables_prefix', Piwik_Translate('Installation_DatabaseSetupTablePrefix'), 'value='.'piwik_'),
|
||||
array('select', 'adapter', Piwik_Translate('Installation_DatabaseSetupAdapter'), $adapters),
|
||||
);
|
||||
$this->addElements( $formElements );
|
||||
|
||||
$formRules = array();
|
||||
foreach($formElements as $row)
|
||||
{
|
||||
if($row[1] != 'password' && $row[1] != 'tables_prefix')
|
||||
{
|
||||
$formRules[] = array($row[1], Piwik_Translate('General_Required', $row[2]), 'required');
|
||||
}
|
||||
}
|
||||
$this->addRules( $formRules );
|
||||
|
||||
$this->addElement('submit', 'submit', Piwik_Translate('Installation_SubmitGo'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?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: FormFirstWebsiteSetup.php 2071 2010-04-09 13:41:27Z matt $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_Installation
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_Installation
|
||||
*/
|
||||
class Piwik_Installation_FormFirstWebsiteSetup extends Piwik_Form
|
||||
{
|
||||
function validate()
|
||||
{
|
||||
try {
|
||||
$timezone = $this->getSubmitValue('timezone');
|
||||
if(!empty($timezone))
|
||||
{
|
||||
Piwik_SitesManager_API::getInstance()->setDefaultTimezone($timezone);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->_errors['timezone'] = Piwik_Translate('General_NotValid', Piwik_Translate('Installation_Timezone'));
|
||||
}
|
||||
return parent::validate();
|
||||
}
|
||||
|
||||
function init()
|
||||
{
|
||||
$urlToGoAfter = 'index.php' . Piwik_Url::getCurrentQueryString();
|
||||
|
||||
$urlExample = 'http://example.org';
|
||||
$javascriptOnClickUrlExample = "\"javascript:if(this.value=='$urlExample'){this.value='http://';} this.style.color='black';\"";
|
||||
|
||||
$timezones = Piwik_SitesManager_API::getInstance()->getTimezonesList();
|
||||
$timezones = array_merge(array('No timezone' => Piwik_Translate('SitesManager_SelectACity')), $timezones);
|
||||
|
||||
$formElements = array(
|
||||
array('text', 'siteName', Piwik_Translate('Installation_SetupWebSiteName')),
|
||||
array('text', 'url', Piwik_Translate('Installation_SetupWebSiteURL'), "style='color:rgb(153, 153, 153);' value=$urlExample onfocus=".$javascriptOnClickUrlExample." onclick=".$javascriptOnClickUrlExample),
|
||||
array('select', 'timezone', Piwik_Translate('Installation_Timezone'), $timezones),
|
||||
|
||||
);
|
||||
$this->addElements( $formElements );
|
||||
|
||||
$formRules = array();
|
||||
foreach($formElements as $row)
|
||||
{
|
||||
$formRules[] = array($row[1], Piwik_Translate('General_Required', $row[2]), 'required');
|
||||
}
|
||||
|
||||
|
||||
$submitTimezone = $this->getSubmitValue('timezone');
|
||||
if(!$this->isSubmitted()
|
||||
|| !empty($submitTimezone))
|
||||
{
|
||||
$this->setSelected('timezone', $submitTimezone);
|
||||
}
|
||||
$this->addRules( $formRules );
|
||||
|
||||
$this->addElement('submit', 'submit', Piwik_Translate('Installation_SubmitGo'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?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: FormGeneralSetup.php 2070 2010-04-09 13:36:32Z matt $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_Installation
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_Installation
|
||||
*/
|
||||
class Piwik_Installation_FormGeneralSetup extends Piwik_Form
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct($action = '', $attributes = 'autocomplete="off"');
|
||||
}
|
||||
|
||||
function validate()
|
||||
{
|
||||
try {
|
||||
$login = $this->getSubmitValue('login');
|
||||
if(!empty($login))
|
||||
{
|
||||
Piwik::checkValidLoginString($login);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->_errors['login'] = $e->getMessage();
|
||||
}
|
||||
return parent::validate();
|
||||
}
|
||||
|
||||
function init()
|
||||
{
|
||||
$urlToGoAfter = 'index.php' . Piwik_Url::getCurrentQueryString();
|
||||
|
||||
$formElements = array(
|
||||
array('text', 'login', Piwik_Translate('Installation_SuperUserLogin')),
|
||||
array('password', 'password', Piwik_Translate('Installation_Password')),
|
||||
array('password', 'password_bis', Piwik_Translate('Installation_PasswordRepeat')),
|
||||
array('text', 'email', Piwik_Translate('Installation_Email')),
|
||||
array('checkbox', 'subscribe_newsletter_security', '', ' ' . Piwik_Translate('Installation_SecurityNewsletter')),
|
||||
array('checkbox', 'subscribe_newsletter_community', '', ' '. Piwik_Translate('Installation_CommunityNewsletter')),
|
||||
);
|
||||
$this->addElements( $formElements );
|
||||
|
||||
if(!$this->isSubmitted()
|
||||
|| $this->getSubmitValue('subscribe_newsletter_community') == '1')
|
||||
{
|
||||
$this->setChecked('subscribe_newsletter_community');
|
||||
}
|
||||
if(!$this->isSubmitted()
|
||||
|| $this->getSubmitValue('subscribe_newsletter_security') == '1')
|
||||
{
|
||||
$this->setChecked('subscribe_newsletter_security');
|
||||
}
|
||||
|
||||
$formRules = array();
|
||||
foreach($formElements as $row)
|
||||
{
|
||||
// checkboxes are not required (form should validate when unchecked)
|
||||
if(in_array($row[1],array('subscribe_newsletter_security','subscribe_newsletter_community')))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$formRules[] = array($row[1], Piwik_Translate('General_Required', $row[2]), 'required');
|
||||
}
|
||||
|
||||
$formRules[] = array( 'email',
|
||||
Piwik_Translate( 'UsersManager_ExceptionInvalidEmail'),
|
||||
'checkEmail'
|
||||
);
|
||||
$formRules[] = array( 'password',
|
||||
Piwik_Translate( 'Installation_PasswordDoNotMatch'),
|
||||
'fieldHaveSameValue',
|
||||
'password_bis'
|
||||
);
|
||||
|
||||
$this->addRules( $formRules );
|
||||
$this->addElement('submit', 'submit', Piwik_Translate('Installation_SubmitGo'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?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: Installation.php 2264 2010-06-03 16:53:43Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_Installation
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_Installation
|
||||
*/
|
||||
class Piwik_Installation extends Piwik_Plugin
|
||||
{
|
||||
protected $installationControllerName = 'Piwik_Installation_Controller';
|
||||
|
||||
public function getInformation()
|
||||
{
|
||||
$info = array(
|
||||
'description' => Piwik_Translate('Installation_PluginDescription'),
|
||||
'author' => 'Piwik',
|
||||
'author_homepage' => 'http://piwik.org/',
|
||||
'version' => Piwik_Version::VERSION,
|
||||
);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function getListHooksRegistered()
|
||||
{
|
||||
$hooks = array(
|
||||
'FrontController.NoConfigurationFile' => 'dispatch',
|
||||
'FrontController.badConfigurationFile' => 'dispatch',
|
||||
);
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
public function setControllerToLoad( $newControllerName )
|
||||
{
|
||||
$this->installationControllerName = $newControllerName;
|
||||
}
|
||||
|
||||
protected function getInstallationController()
|
||||
{
|
||||
return new $this->installationControllerName();
|
||||
}
|
||||
|
||||
function dispatch($notification = null)
|
||||
{
|
||||
if($notification)
|
||||
{
|
||||
$exception = $notification->getNotificationObject();
|
||||
$message = $exception->getMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = '';
|
||||
}
|
||||
|
||||
Piwik_Translate::getInstance()->loadUserTranslation();
|
||||
|
||||
Piwik_PostEvent('Installation.startInstallation', $this);
|
||||
|
||||
$step = Piwik_Common::getRequestVar('action', 'welcome', 'string');
|
||||
$controller = $this->getInstallationController();
|
||||
if(in_array($step, array_keys($controller->getInstallationSteps())) || $step == 'saveLanguage')
|
||||
{
|
||||
$controller->$step($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Piwik::exitWithErrorMessage(Piwik_Translate('Installation_NoConfigFound'));
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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: View.php 2058 2010-04-07 10:26:32Z matt $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_Installation
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_Installation
|
||||
*/
|
||||
class Piwik_Installation_View extends Piwik_View
|
||||
{
|
||||
protected $mainTemplate = 'Installation/templates/structure.tpl';
|
||||
|
||||
function __construct($subtemplatePath, $installationSteps, $currentStepName)
|
||||
{
|
||||
parent::__construct($this->mainTemplate);
|
||||
|
||||
$this->subTemplateToLoad = $subtemplatePath;
|
||||
$this->steps = array_keys($installationSteps);
|
||||
$this->allStepsTitle = array_values($installationSteps);
|
||||
$this->currentStepName = $currentStepName;
|
||||
$this->showNextStep = false;
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
// prepare the all steps templates
|
||||
$this->currentStepId = array_search($this->currentStepName, $this->steps);
|
||||
$this->totalNumberOfSteps = count($this->steps);
|
||||
|
||||
$this->percentDone = round(($this->currentStepId) * 100 / ($this->totalNumberOfSteps-1));
|
||||
$this->percentToDo = 100 - $this->percentDone;
|
||||
|
||||
$this->nextModuleName = '';
|
||||
if(isset($this->steps[$this->currentStepId + 1]))
|
||||
{
|
||||
$this->nextModuleName = $this->steps[$this->currentStepId + 1];
|
||||
}
|
||||
$this->previousModuleName = '';
|
||||
if(isset($this->steps[$this->currentStepId - 1]))
|
||||
{
|
||||
$this->previousModuleName = $this->steps[$this->currentStepId - 1];
|
||||
}
|
||||
$this->previousPreviousModuleName = '';
|
||||
if(isset($this->steps[$this->currentStepId - 2]))
|
||||
{
|
||||
$this->previousPreviousModuleName = $this->steps[$this->currentStepId - 2];
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<ul>
|
||||
{foreach from=$allStepsTitle key=stepId item=stepName}
|
||||
{if $currentStepId > $stepId}
|
||||
<li class="pastStep">{$stepName|translate}</li>
|
||||
{elseif $currentStepId == $stepId}
|
||||
<li class="actualStep">{$stepName|translate}</li>
|
||||
{else}
|
||||
<li class="futureStep">{$stepName|translate}</li>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</ul>
|
||||
@@ -0,0 +1,34 @@
|
||||
{assign var=ok value="<img src='themes/default/images/ok.png' />"}
|
||||
{assign var=error value="<img src='themes/default/images/error.png' />"}
|
||||
{assign var=warning value="<img src='themes/default/images/warning.png' />"}
|
||||
{assign var=link value="<img src='themes/default/images/link.gif' />"}
|
||||
|
||||
<h1>{'Installation_DatabaseCheck'|translate}</h1>
|
||||
|
||||
<table class="infosServer">
|
||||
<tr>
|
||||
<td class="label">{'Installation_DatabaseServerVersion'|translate}</td>
|
||||
<td>{if isset($databaseVersionOk)}{$ok}{else}{$error}{/if}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{'Installation_DatabaseClientVersion'|translate}</td>
|
||||
<td>{if isset($clientVersionWarning)}{$warning}{else}{$ok}{/if}</td>
|
||||
</tr>
|
||||
{if isset($clientVersionWarning)}
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<small>
|
||||
<span style="color:#FF7F00">{$clientVersionWarning}</span>
|
||||
</small>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td class="label">{'Installation_DatabaseCreation'|translate}</td>
|
||||
<td>{if isset($databaseCreated)}{$ok}{else}{$error}{/if}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
{$link} <a href="misc/redirectToUrl.php?url=http://piwik.org/docs/requirements/" target="_blank">{'Installation_Requirements'|translate}</a>
|
||||
</p>
|
||||
@@ -0,0 +1,14 @@
|
||||
<h1>{'Installation_DatabaseSetup'|translate}</h1>
|
||||
|
||||
{if isset($errorMessage)}
|
||||
<div class="error">
|
||||
<img src="themes/default/images/error_medium.png" />
|
||||
{'Installation_DatabaseErrorConnect'|translate}:
|
||||
<br />{$errorMessage}
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if isset($form_data)}
|
||||
{include file=default/genericForm.tpl}
|
||||
{/if}
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
{literal}
|
||||
<style>
|
||||
code {
|
||||
background-color:#F0F7FF;
|
||||
border-color:#00008B;
|
||||
border-style:dashed dashed dashed solid;
|
||||
border-width:1px 1px 1px 5px;
|
||||
direction:ltr;
|
||||
display:block;
|
||||
font-size:80%;
|
||||
margin:2px 2px 20px;
|
||||
padding:4px;
|
||||
text-align:left;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
$(document).ready( function(){
|
||||
$('code').click( function(){ $(this).select(); });
|
||||
});
|
||||
</script>
|
||||
|
||||
{/literal}
|
||||
|
||||
{if isset($displayfirstWebsiteSetupSuccess)}
|
||||
|
||||
<span id="toFade" class="success">
|
||||
{'Installation_SetupWebsiteSetupSuccess'|translate:$websiteName}
|
||||
<img src="themes/default/images/success_medium.png" />
|
||||
</span>
|
||||
{/if}
|
||||
<h1>{'Installation_JsTag'|translate}</h1>
|
||||
{'Installation_JsTagHelp'|translate}
|
||||
<code>
|
||||
{$javascriptTag}
|
||||
</code>
|
||||
|
||||
<h1>{'Installation_JsTagHelpTitle'|translate}</h1>
|
||||
{include file=SitesManager/templates/JavascriptTagHelp.tpl}
|
||||
|
||||
<br />
|
||||
<h1>{'Installation_LargePiwikInstances'|translate}</h1>
|
||||
{'Installation_JsTagArchivingHelp'|translate}
|
||||
<!-- <li>Link to help with the main blog engines wordpress/drupal/myspace/blogspot</li> -->
|
||||
@@ -0,0 +1,8 @@
|
||||
<h1>{'Installation_Congratulations'|translate}</h1>
|
||||
|
||||
{'Installation_CongratulationsHelp'|translate}
|
||||
|
||||
|
||||
<p class="nextStep">
|
||||
<a href="index.php">{'Installation_ContinueToPiwik'|translate} »</a>
|
||||
</p>
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
{if isset($displayGeneralSetupSuccess)}
|
||||
<span id="toFade" class="success">
|
||||
{'Installation_GeneralSetupSuccess'|translate}
|
||||
<img src="themes/default/images/success_medium.png" />
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
<h1>{'Installation_SetupWebsite'|translate}</h1>
|
||||
|
||||
{if isset($errorMessage)}
|
||||
<div class="error">
|
||||
<img src="themes/default/images/error_medium.png" />
|
||||
{'Installation_SetupWebsiteError'|translate}:
|
||||
<br />- {$errorMessage}
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if isset($form_data)}
|
||||
{include file=default/genericForm.tpl}
|
||||
{/if}
|
||||
@@ -0,0 +1,5 @@
|
||||
<h1>{'Installation_GeneralSetup'|translate}</h1>
|
||||
|
||||
{if isset($form_data)}
|
||||
{include file=default/genericForm.tpl}
|
||||
{/if}
|
||||
@@ -0,0 +1,43 @@
|
||||
{if !isset($warningMessages)}
|
||||
{assign var=warningMessages value=$infos.integrityErrorMessages}
|
||||
{/if}
|
||||
<div id="integrity-results" title="{'Installation_SystemCheckFileIntegrity'|translate}" style="display:none; font-size: 62.5%;">
|
||||
<table>
|
||||
{foreach from=$warningMessages item=msg}
|
||||
<tr><td>{$msg}</td></tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
{literal}<!--
|
||||
$(function() {
|
||||
$("#integrity-results").dialog({
|
||||
bgiframe: true,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
width: 600,
|
||||
buttons: {
|
||||
Ok: function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#more-results').click(function() {
|
||||
$('#integrity-results').dialog('open');
|
||||
})
|
||||
.hover(
|
||||
function(){
|
||||
$(this).addClass("ui-state-hover");
|
||||
},
|
||||
function(){
|
||||
$(this).removeClass("ui-state-hover");
|
||||
}
|
||||
).mousedown(function(){
|
||||
$(this).addClass("ui-state-active");
|
||||
})
|
||||
.mouseup(function(){
|
||||
$(this).removeClass("ui-state-active");
|
||||
});
|
||||
//-->{/literal}
|
||||
</script>
|
||||
@@ -0,0 +1,241 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Piwik › {'Installation_Installation'|translate}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="themes/default/common.css" />
|
||||
<link rel="stylesheet" type="text/css" href="libs/jquery/themes/base/jquery-ui.css" />
|
||||
<link rel="stylesheet" type="text/css" href="themes/default/styles.css" />
|
||||
|
||||
<script type="text/javascript" src="libs/jquery/jquery.js"></script>
|
||||
<script type="text/javascript" src="libs/jquery/jquery-ui.js"></script>
|
||||
<script type="text/javascript" src="libs/jquery/fdd2div-modified.js"></script>
|
||||
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
$(document).ready( function(){
|
||||
$('#toFade').fadeOut(4000, function(){ $(this).css('display', 'hidden'); } );
|
||||
$('input:first').focus();
|
||||
$('#progressbar').progressbar({
|
||||
{/literal}
|
||||
value: {$percentDone}
|
||||
{literal}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
{literal}
|
||||
<style type="text/css">
|
||||
div.both {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #F9F9F9;
|
||||
text-align: center;
|
||||
font-family:Georgia,"Times New Roman",Times,serif;
|
||||
font-size:19px;
|
||||
}
|
||||
|
||||
#title{
|
||||
font-size:50px;
|
||||
color:#284F92;
|
||||
}
|
||||
|
||||
#subtitle{
|
||||
font-size:30px;
|
||||
color:#C7D8D2;
|
||||
}
|
||||
|
||||
#logo {
|
||||
padding:30px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size:20px;
|
||||
color:#666666;
|
||||
border-bottom:1px solid #DADADA;
|
||||
padding:0 0 7px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-top:10px;
|
||||
font-size:17px;
|
||||
color:#3F5163;
|
||||
}
|
||||
|
||||
.topBarElem {
|
||||
font-family:arial,sans-serif !important;
|
||||
font-size:13px;
|
||||
line-height:1.33;
|
||||
}
|
||||
|
||||
.error {
|
||||
color:red;
|
||||
font-size:100%;
|
||||
font-weight:bold;
|
||||
border: 1px solid red;
|
||||
width: 550px;
|
||||
padding:20;
|
||||
}
|
||||
.error img {
|
||||
border:0;
|
||||
float:right;
|
||||
margin:10;
|
||||
}
|
||||
.success {
|
||||
color:#26981C;
|
||||
font-size:130%;
|
||||
font-weight:bold;
|
||||
padding:10;
|
||||
}
|
||||
.warning {
|
||||
margin:10px;
|
||||
color:#ff5502;
|
||||
font-size:130%;
|
||||
font-weight:bold;
|
||||
padding:10px 20px 10px 30px;
|
||||
border: 1px solid #ff5502;
|
||||
}
|
||||
|
||||
.warning ul {
|
||||
list-style:disc;
|
||||
}
|
||||
|
||||
.success img, .warning img {
|
||||
border:0;
|
||||
vertical-align:bottom;
|
||||
}
|
||||
|
||||
#detailInstall {
|
||||
width:70%;
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* Cadre general */
|
||||
#main {
|
||||
margin: 5px;
|
||||
margin-top:30px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#content {
|
||||
font-size: 90%;
|
||||
line-height: 1.4em;
|
||||
width: 860px;
|
||||
border: 1px solid #3B62AF;
|
||||
text-align: $rightouleft;
|
||||
margin: auto;
|
||||
background: #FFFFFF;
|
||||
padding: 0.2em 2em 2em 2em;
|
||||
-moz-border-radius: 8px;
|
||||
-webkit-border-radius: 8px;
|
||||
}
|
||||
/* form errors */
|
||||
#adminErrors {
|
||||
color:#FF6E46;
|
||||
font-size:120%;
|
||||
}
|
||||
/* listing all the steps */
|
||||
#generalInstall {
|
||||
width: 30%;
|
||||
float: left;
|
||||
font-size:90%;
|
||||
}
|
||||
|
||||
#generalInstall ul {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
li.futureStep {
|
||||
color: #d3d3d3;
|
||||
}
|
||||
li.actualStep {
|
||||
font-weight: bold;
|
||||
}
|
||||
li.pastStep {
|
||||
color: #008000;
|
||||
}
|
||||
|
||||
p.nextStep a {
|
||||
font-weight: bold;
|
||||
padding: 0.5em;
|
||||
color: #ae0000;
|
||||
text-decoration: underline;
|
||||
float:right;
|
||||
font-size:35px;
|
||||
line-height:1em;
|
||||
}
|
||||
|
||||
td {
|
||||
border-color:#FFFFFF rgb(198, 205, 216) rgb(198, 205, 216) rgb(198, 205, 216) ;
|
||||
border-style:solid;
|
||||
border-width:1px;
|
||||
color:#203276;
|
||||
padding:0.5em 0.5em 0.5em 0.8em;
|
||||
}
|
||||
|
||||
.submit {
|
||||
text-align:center;
|
||||
}
|
||||
.submit input{
|
||||
margin-top:15px;
|
||||
background:transparent url(./themes/default/images/background-submit.png) repeat scroll 0%;
|
||||
font-size:1.4em;
|
||||
border-color:#CCCCCC rgb(153, 153, 153) rgb(153, 153, 153) rgb(204, 204, 204);
|
||||
border-style:double;
|
||||
border-width:3px;
|
||||
color:#333333;
|
||||
padding:0.15em;
|
||||
}
|
||||
|
||||
input {
|
||||
font-size:1.1em;
|
||||
border-color:#CCCCCC rgb(153, 153, 153) rgb(153, 153, 153) rgb(204, 204, 204);
|
||||
border-width:1px;
|
||||
color:#3A2B16;
|
||||
padding:0.15em;
|
||||
}
|
||||
</style>
|
||||
{/literal}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
<div id="content">
|
||||
<div id="logo">
|
||||
<span id="title">Piwik</span> <span id="subtitle"># {'General_OpenSourceWebAnalytics'|translate}</span>
|
||||
</div>
|
||||
<div style="float:right" id="topRightBar">
|
||||
<br />
|
||||
{postEvent name="template_topBar"}
|
||||
</div>
|
||||
<div class="both"></div>
|
||||
|
||||
<div id="generalInstall">
|
||||
{include file="Installation/templates/allSteps.tpl"}
|
||||
</div>
|
||||
|
||||
<div id="detailInstall">
|
||||
{include file="$subTemplateToLoad"}
|
||||
{if $showNextStep}
|
||||
<p class="nextStep">
|
||||
<a href="{url action=$nextModuleName}">{'General_Next'|translate} »</a>
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="both"></div>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<h3>{'Installation_InstallationStatus'|translate}</h3>
|
||||
|
||||
<div id="progressbar"></div>
|
||||
{'Installation_PercentDone'|translate:$percentDone}
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,256 @@
|
||||
{assign var=ok value="<img src='themes/default/images/ok.png' />"}
|
||||
{assign var=error value="<img src='themes/default/images/error.png' />"}
|
||||
{assign var=warning value="<img src='themes/default/images/warning.png' />"}
|
||||
{assign var=link value="<img src='themes/default/images/link.gif' />"}
|
||||
|
||||
<h1>{'Installation_SystemCheck'|translate}</h1>
|
||||
|
||||
<table class="infosServer">
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckPhp'|translate} > {$infos.phpVersion_minimum}</td>
|
||||
<td>{if $infos.phpVersion_ok}{$ok}{else}{$error}{/if}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">PDO {'Installation_Extension'|translate}</td>
|
||||
<td>{if $infos.pdo_ok}{$ok}
|
||||
{else}-{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{foreach from=$infos.adapters key=adapter item=port}
|
||||
<tr>
|
||||
<td class="label">{$adapter} {'Installation_Extension'|translate}</td>
|
||||
<td>{$ok}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{if !count($infos.adapters)}
|
||||
<tr>
|
||||
<td colspan="2" class="error">
|
||||
<small>
|
||||
{'Installation_SystemCheckDatabaseHelp'|translate}
|
||||
<p>
|
||||
{if $infos.isWindows}
|
||||
{'Installation_SystemCheckWinPdoAndMysqliHelp'|translate:"<br /><br /><code>extension=php_mysqli.dll</code><br /><code>extension=php_pdo.dll</code><br /><code>extension=php_pdo_mysql.dll</code><br />"|nl2br}
|
||||
{else}
|
||||
{'Installation_SystemCheckPdoAndMysqliHelp'|translate:"<br /><br /><code>--with-mysqli</code><br /><code>--with-pdo-mysql</code><br />":"<br /><br /><code>extension=mysqli.so</code><br /><code>extension=pdo.so</code><br /><code>extension=pdo_mysql.so</code><br />"|nl2br}
|
||||
{/if}
|
||||
<br />
|
||||
{'Installation_SystemCheckPhpPdoAndMysqliSite'|translate}
|
||||
</p>
|
||||
</small>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td valign="top">
|
||||
{'Installation_SystemCheckJson'|translate}
|
||||
</td>
|
||||
<td>{if $infos.json || $infos.xml}{$ok}
|
||||
{else}{$error}{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{if !$infos.json && !$infos.xml}
|
||||
<tr>
|
||||
<td colspan="2" class="error">
|
||||
<small>
|
||||
{'Installation_SystemCheckJsonHelp'|translate}
|
||||
<br />
|
||||
{if version_compare($infos.phpVersion, '5.2.0') >= 0}
|
||||
{'Installation_SystemCheckJsonSite'|translate}
|
||||
{else}
|
||||
{'Installation_SystemCheckXmlSite'|translate}
|
||||
{/if}
|
||||
</small>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckExtensions'|translate}</td>
|
||||
<td>{foreach from=$infos.needed_extensions item=needed_extension}
|
||||
{$needed_extension}
|
||||
{if in_array($needed_extension, $infos.missing_extensions)}
|
||||
{$error}
|
||||
{else}
|
||||
{$ok}
|
||||
{/if}
|
||||
<br />
|
||||
{/foreach}
|
||||
</td>
|
||||
</tr>
|
||||
{if count($infos.missing_extensions) gt 0}
|
||||
<tr>
|
||||
<td colspan="2" class="error">
|
||||
<small>
|
||||
{foreach from=$infos.missing_extensions item=missing_extension}
|
||||
<p>
|
||||
<i>{$helpMessages[$missing_extension]|translate}</i>
|
||||
</p>
|
||||
{/foreach}
|
||||
</small>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckFunctions'|translate}</td>
|
||||
<td>{foreach from=$infos.needed_functions item=needed_function}
|
||||
{$needed_function}
|
||||
{if in_array($needed_function, $infos.missing_functions)}
|
||||
{$error}
|
||||
<p>
|
||||
<i>{$helpMessages[$needed_function]|translate}</i>
|
||||
</p>
|
||||
{else}
|
||||
{$ok}<br />
|
||||
{/if}
|
||||
{/foreach}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
{'Installation_SystemCheckWriteDirs'|translate}
|
||||
</td>
|
||||
<td>
|
||||
<small>
|
||||
{foreach from=$infos.directories key=dir item=bool}
|
||||
{if $bool}{$ok}{else}
|
||||
<span style="color:red">{$error}</span>{/if}
|
||||
{$dir}
|
||||
<br />
|
||||
{/foreach}
|
||||
</small>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{if $problemWithSomeDirectories}
|
||||
<br />
|
||||
<div class="error">
|
||||
{'Installation_SystemCheckWriteDirsHelp'|translate}:
|
||||
{foreach from=$infos.directories key=dir item=bool}
|
||||
<ul>{if !$bool}
|
||||
<li><pre>chmod a+w {$dir}</pre></li>
|
||||
{/if}
|
||||
</ul>
|
||||
{/foreach}
|
||||
</div>
|
||||
<br />
|
||||
{/if}
|
||||
<h1>{'Optional'|translate}</h1>
|
||||
<table class="infos">
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckFileIntegrity'|translate}</td>
|
||||
<td>
|
||||
{if empty($infos.integrityErrorMessages)}
|
||||
{$ok}
|
||||
{else}
|
||||
{if $infos.integrity}
|
||||
{$warning} <i>{$infos.integrityErrorMessages[0]}</i>
|
||||
{else}
|
||||
{$error} <i>{$infos.integrityErrorMessages[0]}</i>
|
||||
{/if}
|
||||
{if count($infos.integrityErrorMessages) > 1}
|
||||
<button id="more-results" class="ui-button ui-state-default ui-corner-all">{'General_Details'|translate}</button>
|
||||
{/if}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckMemoryLimit'|translate}</td>
|
||||
<td>
|
||||
{$infos.memoryCurrent}
|
||||
{if $infos.memory_ok}{$ok}{else}{$warning}
|
||||
<br /><i>{'Installation_SystemCheckMemoryLimitHelp'|translate}</i>{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{'SitesManager_Timezone'|translate}</td>
|
||||
<td>
|
||||
{if $infos.timezone}{$ok}{else}{$warning}
|
||||
<br /><i>{'SitesManager_AdvancedTimezoneSupportNotFound'|translate}</i>{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckOpenURL'|translate}</td>
|
||||
<td>
|
||||
{if $infos.openurl}{$infos.openurl} {$ok}{else}{$warning} <br /><i>{'Installation_SystemCheckOpenURLHelp'|translate}</i>{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{if $infos.json}
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckXml'|translate}</td>
|
||||
<td>
|
||||
{if $infos.xml}{$ok}{else}{$warning}<br /><i>{'Installation_SystemCheckXmlHelp'|translate}</i>{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckGD'|translate}</td>
|
||||
<td>
|
||||
{if $infos.gd_ok}{$ok}{else}{$warning} <br /><i>{'Installation_SystemCheckGDHelp'|translate}</i>{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{if $infos.hasMbstring}
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckMbstring'|translate}</td>
|
||||
<td>
|
||||
{if $infos.multibyte_ok}{$ok}{else}{$warning} <br /><i>{'Installation_SystemCheckMbstringHelp'|translate}</i>{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckFunctions'|translate}</td>
|
||||
<td>{foreach from=$infos.desired_functions item=desired_function}
|
||||
{$desired_function}
|
||||
{if in_array($desired_function, $infos.missing_desired_functions)}
|
||||
{$warning}
|
||||
<p>
|
||||
<i>{$helpMessages[$desired_function]|translate}</i>
|
||||
</p>
|
||||
{else}
|
||||
{$ok}<br />
|
||||
{/if}
|
||||
{/foreach}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckProtocol'|translate}</td>
|
||||
<td>
|
||||
{if $infos.protocol_ok}{$ok}{else}{$warning} {$infos.protocol}<br /><i>{'Installation_SystemCheckProtocolHelp'|translate}</i><br /><br /><code>[General]</code><br /><code>reverse_proxy = 1</code><br />{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{'Installation_SystemCheckIpv4'|translate}</td>
|
||||
<td>
|
||||
{if $infos.isIpv4}{$ok}{else}{$warning}<br /><i>{'Installation_SystemCheckIpv4Help'|translate}</i>{/if}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{include file="Installation/templates/integrityDetails.tpl"}
|
||||
|
||||
<p>
|
||||
{$link} <a href="misc/redirectToUrl.php?url=http://piwik.org/docs/requirements/" target="_blank">{'Installation_Requirements'|translate}</a>
|
||||
</p>
|
||||
|
||||
{if !$showNextStep}
|
||||
{literal}
|
||||
<style>
|
||||
#legend {
|
||||
border:1px solid #A5A5A5;
|
||||
padding:5px;
|
||||
color:#727272;
|
||||
margin-top:30px;
|
||||
}
|
||||
</style>
|
||||
{/literal}
|
||||
<div id="legend"><small>
|
||||
<b>{'Installation_Legend'|translate}</b>
|
||||
<br />
|
||||
{$ok} {'General_Ok'|translate}<br />
|
||||
{$error} {'General_Error'|translate}: {'Installation_SystemCheckError'|translate} <br />
|
||||
{$warning} {'General_Warning'|translate}: {'Installation_SystemCheckWarning'|translate} <br />
|
||||
</small></div>
|
||||
|
||||
|
||||
<p class="nextStep">
|
||||
<a href="{url}">{'General_Refresh'|translate} »</a>
|
||||
</p>
|
||||
{/if}
|
||||
@@ -0,0 +1,63 @@
|
||||
<h1>{'Installation_Tables'|translate}</h1>
|
||||
|
||||
{if isset($someTablesInstalled)}
|
||||
<div class="warning">{'Installation_TablesWithSameNamesFound'|translate:"<span id='linkToggle'>":"</span>"}
|
||||
<img src="themes/default/images/warning_medium.png" />
|
||||
</div>
|
||||
<div id="toggle" style="display:none;color:#4F2410"><small><i>{'Installation_TablesFound'|translate}:
|
||||
<br />{$tablesInstalled} </i></small></div>
|
||||
|
||||
{if isset($showReuseExistingTables)}
|
||||
<p>{'Installation_TablesWarningHelp'|translate}</p>
|
||||
<p class="nextStep"><a href="{url action=$nextModuleName}">{'Installation_TablesReuse'|translate} »</a></p>
|
||||
{else}
|
||||
<p class="nextStep"><a href="{url action=$previousPreviousModuleName}">« {'Installation_GoBackAndDefinePrefix'|translate}</a></p>
|
||||
{/if}
|
||||
|
||||
<p class="nextStep"><a href="{url deleteTables=1}" id="eraseAllTables">{'Installation_TablesDelete'|translate} »</a></p>
|
||||
{/if}
|
||||
|
||||
{if isset($existingTablesDeleted)}
|
||||
<div class="success"> {'Installation_TablesDeletedSuccess'|translate}
|
||||
<img src="themes/default/images/success_medium.png" /></div>
|
||||
{/if}
|
||||
|
||||
{if isset($tablesCreated)}
|
||||
<div class="success"> {'Installation_TablesCreatedSuccess'|translate}
|
||||
<img src="themes/default/images/success_medium.png" /></div>
|
||||
{/if}
|
||||
|
||||
{literal}
|
||||
<script>
|
||||
$(document).ready( function(){
|
||||
{/literal}
|
||||
var strConfirmEraseTables = "{'Installation_ConfirmDeleteExistingTables'|translate:"[$tablesInstalled]":"<br />"} ";
|
||||
{literal}
|
||||
|
||||
// toggle the display of the tables detected during the installation when clicking
|
||||
// on the span "linkToggle"
|
||||
$("#linkToggle")
|
||||
.css("border-bottom","thin dotted #ff5502")
|
||||
|
||||
.hover( function() {
|
||||
$(this).css({ cursor: "pointer"});
|
||||
},
|
||||
function() {
|
||||
$(this).css({ cursor: "auto"});
|
||||
})
|
||||
.css("border-bottom","thin dotted #ff5502")
|
||||
.click(function(){
|
||||
$("#toggle").toggle();} );
|
||||
|
||||
$("#eraseAllTables")
|
||||
.click( function(){
|
||||
if(!confirm( strConfirmEraseTables ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
;
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
@@ -0,0 +1,29 @@
|
||||
<h1>{'Installation_Welcome'|translate}</h1>
|
||||
|
||||
{if $newInstall}
|
||||
{'Installation_WelcomeHelp'|translate:$totalNumberOfSteps}
|
||||
{else}
|
||||
<p>{'Installation_ConfigurationHelp'|translate}</p>
|
||||
<br />
|
||||
<div class="error">
|
||||
{$errorMessage}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
$(function() {
|
||||
if (document.location.protocol === 'https:') {
|
||||
$('p.nextStep a').attr('href', $('p.nextStep a').attr('href') + '&clientProtocol=https');
|
||||
}
|
||||
});
|
||||
//-->
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
{if !$showNextStep}
|
||||
<p class="nextStep">
|
||||
<a href="{url}">{'General_Refresh'|translate} »</a>
|
||||
</p>
|
||||
{/if}
|
||||
@@ -0,0 +1,197 @@
|
||||
<?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: API.php 2265 2010-06-03 17:46:05Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_LanguagesManager
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_LanguagesManager
|
||||
*/
|
||||
class Piwik_LanguagesManager_API
|
||||
{
|
||||
static private $instance = null;
|
||||
static public function getInstance()
|
||||
{
|
||||
if (self::$instance == null)
|
||||
{
|
||||
$c = __CLASS__;
|
||||
self::$instance = new $c();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
protected $availableLanguageNames = null;
|
||||
protected $languageNames = null;
|
||||
|
||||
/**
|
||||
* Returns true if specified language is available
|
||||
*
|
||||
* @param string $languageCode
|
||||
* @return bool true if language available; false otherwise
|
||||
*/
|
||||
public function isLanguageAvailable($languageCode)
|
||||
{
|
||||
return $languageCode !== false
|
||||
&& in_array($languageCode, $this->getAvailableLanguages());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of available languages
|
||||
*
|
||||
* @return array Arry of strings, each containing its ISO language code
|
||||
*/
|
||||
public function getAvailableLanguages()
|
||||
{
|
||||
if(!is_null($this->languageNames))
|
||||
{
|
||||
return $this->languageNames;
|
||||
}
|
||||
$path = PIWIK_INCLUDE_PATH . "/lang/";
|
||||
$languages = glob($path . "*.php");
|
||||
$pathLength = strlen($path);
|
||||
$languageNames = array();
|
||||
foreach($languages as $language)
|
||||
{
|
||||
$languageNames[] = substr($language, $pathLength, -strlen('.php'));
|
||||
}
|
||||
$this->languageNames = $languageNames;
|
||||
return $languageNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return information on translations (code, language, % translated, etc)
|
||||
*
|
||||
* @return array Array of arrays
|
||||
*/
|
||||
public function getAvailableLanguagesInfo()
|
||||
{
|
||||
require PIWIK_INCLUDE_PATH . '/lang/en.php';
|
||||
$englishTranslation = $translations;
|
||||
$filenames = $this->getAvailableLanguages();
|
||||
$languagesInfo = array();
|
||||
foreach($filenames as $filename)
|
||||
{
|
||||
require PIWIK_INCLUDE_PATH . "/lang/$filename.php";
|
||||
$translationStringsDone = array_intersect_key($englishTranslation, array_filter($translations, 'strlen'));
|
||||
$percentageComplete = count($translationStringsDone) / count($englishTranslation);
|
||||
$percentageComplete = round(100 * $percentageComplete, 0);
|
||||
$languageInfo = array( 'code' => $filename,
|
||||
'name' => $translations['General_OriginalLanguageName'],
|
||||
'english_name' => $translations['General_EnglishLanguageName'],
|
||||
'translators' => $translations['General_TranslatorName'],
|
||||
'translators_email' => $translations['General_TranslatorEmail'],
|
||||
'percentage_complete' => $percentageComplete . '%',
|
||||
);
|
||||
$languagesInfo[] = $languageInfo;
|
||||
}
|
||||
return $languagesInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of available languages
|
||||
*
|
||||
* @return array Arry of array, each containing its ISO language code and name of the language
|
||||
*/
|
||||
public function getAvailableLanguageNames()
|
||||
{
|
||||
if(!is_null($this->availableLanguageNames))
|
||||
{
|
||||
return $this->availableLanguageNames;
|
||||
}
|
||||
|
||||
$filenames = $this->getAvailableLanguages();
|
||||
$languagesInfo = array();
|
||||
foreach($filenames as $filename)
|
||||
{
|
||||
require PIWIK_INCLUDE_PATH . "/lang/$filename.php";
|
||||
$languagesInfo[] = array( 'code' => $filename, 'name' => $translations['General_OriginalLanguageName']);
|
||||
}
|
||||
$this->availableLanguageNames = $languagesInfo;
|
||||
return $this->availableLanguageNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns translation strings by language
|
||||
*
|
||||
* @param string $languageCode ISO language code
|
||||
* @return array|false Array of arrays, each containing 'label' (translation index) and 'value' (translated string); false if language unavailable
|
||||
*/
|
||||
public function getTranslationsForLanguage($languageCode)
|
||||
{
|
||||
if(!$this->isLanguageAvailable($languageCode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
require PIWIK_INCLUDE_PATH . "/lang/$languageCode.php";
|
||||
$languageInfo = array();
|
||||
foreach($translations as $key => $value)
|
||||
{
|
||||
$languageInfo[] = array('label' => $key, 'value' => $value);
|
||||
}
|
||||
return $languageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language for the user
|
||||
*
|
||||
* @param string $login
|
||||
* @param string|false $layout
|
||||
*/
|
||||
public function getLanguageForUser( $login )
|
||||
{
|
||||
Piwik::checkUserIsSuperUserOrTheUser($login);
|
||||
return Piwik_FetchOne('SELECT language FROM '.Piwik_Common::prefixTable('user_language') .
|
||||
' WHERE login = ? ', array($login ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the language for the user
|
||||
*
|
||||
* @param string $login
|
||||
* @param string $languageCode
|
||||
*/
|
||||
public function setLanguageForUser($login, $languageCode)
|
||||
{
|
||||
Piwik::checkUserIsSuperUserOrTheUser($login);
|
||||
$paramsBind = array($login, $languageCode, $languageCode);
|
||||
Piwik_Query('INSERT INTO '.Piwik_Common::prefixTable('user_language') .
|
||||
' (login, language)
|
||||
VALUES (?,?)
|
||||
ON DUPLICATE KEY UPDATE language=?',
|
||||
$paramsBind);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the langage for the session
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLanguageForSession()
|
||||
{
|
||||
$session = new Zend_Session_Namespace("Piwik_LanguagesManager");
|
||||
if(isset($session->language))
|
||||
{
|
||||
return $session->language;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the language for the session
|
||||
*
|
||||
* @param string $languageCode ISO language code
|
||||
*/
|
||||
public function setLanguageForSession($languageCode)
|
||||
{
|
||||
$session = new Zend_Session_Namespace("Piwik_LanguagesManager");
|
||||
$session->language = $languageCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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 1833 2010-02-10 08:26:40Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_LanguagesManager
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package Piwik_LanguagesManager
|
||||
*/
|
||||
class Piwik_LanguagesManager_Controller extends Piwik_Controller
|
||||
{
|
||||
/**
|
||||
* anonymous = in the session
|
||||
* authenticated user = in the session and in DB
|
||||
*/
|
||||
public function saveLanguage()
|
||||
{
|
||||
$language = Piwik_Common::getRequestVar('language');
|
||||
Piwik_LanguagesManager_API::getInstance()->setLanguageForSession($language);
|
||||
if(Zend_Registry::isRegistered('access')) {
|
||||
$currentUser = Piwik::getCurrentUserLogin();
|
||||
if($currentUser && $currentUser !== 'anonymous')
|
||||
{
|
||||
Piwik_LanguagesManager_API::getInstance()->setLanguageForUser($currentUser, $language);
|
||||
}
|
||||
}
|
||||
Piwik_Url::redirectToReferer();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
<?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: LanguagesManager.php 2265 2010-06-03 17:46:05Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_LanguagesManager
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_LanguagesManager
|
||||
*/
|
||||
class Piwik_LanguagesManager extends Piwik_Plugin
|
||||
{
|
||||
public function getInformation()
|
||||
{
|
||||
return array(
|
||||
'description' => Piwik_Translate('LanguagesManager_PluginDescription'),
|
||||
'author' => 'Piwik',
|
||||
'author_homepage' => 'http://piwik.org/',
|
||||
'version' => Piwik_Version::VERSION,
|
||||
);
|
||||
}
|
||||
|
||||
public function getListHooksRegistered()
|
||||
{
|
||||
return array(
|
||||
'template_css_import' => 'css',
|
||||
'template_topBar' => 'showLanguagesSelector',
|
||||
'Translate.getLanguageToLoad' => 'getLanguageToLoad',
|
||||
'UsersManager.deleteUser' => 'deleteUserLanguage',
|
||||
);
|
||||
}
|
||||
|
||||
function css()
|
||||
{
|
||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/default/styles.css\" />\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Show styled language selection drop-down list
|
||||
*
|
||||
* @param string $url The form action. Default is to save language.
|
||||
*/
|
||||
function showLanguagesSelector()
|
||||
{
|
||||
// don't use Piwik_View::factory() here
|
||||
$view = new Piwik_View("LanguagesManager/templates/languages.tpl");
|
||||
$view->languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguageNames();
|
||||
$view->currentLanguageCode = self::getLanguageCodeForCurrentUser();
|
||||
$view->currentLanguageName = self::getLanguageNameForCurrentUser();
|
||||
echo $view->render();
|
||||
}
|
||||
|
||||
function getLanguageToLoad($notification)
|
||||
{
|
||||
$language =& $notification->getNotificationObject();
|
||||
$language = self::getLanguageCodeForCurrentUser();
|
||||
}
|
||||
|
||||
function deleteUserLanguage($notification)
|
||||
{
|
||||
$userLogin = $notification->getNotificationObject();
|
||||
Piwik_Query('DELETE FROM ' . Piwik_Common::prefixTable('user_language') . ' WHERE login = ?', $userLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception if non-recoverable error
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
// we catch the exception
|
||||
try{
|
||||
$sql = "CREATE TABLE ". Piwik_Common::prefixTable('user_language')." (
|
||||
login VARCHAR( 100 ) NOT NULL ,
|
||||
language VARCHAR( 10 ) NOT NULL ,
|
||||
PRIMARY KEY ( login )
|
||||
) DEFAULT CHARSET=utf8 " ;
|
||||
Piwik_Exec($sql);
|
||||
} catch(Exception $e){
|
||||
// mysql code error 1050:table already exists
|
||||
// see bug #153 http://dev.piwik.org/trac/ticket/153
|
||||
if(!Zend_Registry::get('db')->isErrNo($e, '1050'))
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception if non-recoverable error
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
$sql = "DROP TABLE ". Piwik_Common::prefixTable('user_language') ;
|
||||
Piwik_Exec($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string Two letters language code, eg. "fr"
|
||||
*/
|
||||
static public function getLanguageCodeForCurrentUser()
|
||||
{
|
||||
$languageCode = self::getLanguageFromPreferences();
|
||||
if(!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($languageCode))
|
||||
{
|
||||
$languageCode = Piwik_Common::extractLanguageCodeFromBrowserLanguage(Piwik_Common::getBrowserLanguage(), Piwik_LanguagesManager_API::getInstance()->getAvailableLanguages());
|
||||
}
|
||||
if(!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($languageCode))
|
||||
{
|
||||
$languageCode = 'en';
|
||||
}
|
||||
return $languageCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string Full english language string, eg. "French"
|
||||
*/
|
||||
static public function getLanguageNameForCurrentUser()
|
||||
{
|
||||
$languageCode = self::getLanguageCodeForCurrentUser();
|
||||
$languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguageNames();
|
||||
foreach($languages as $language)
|
||||
{
|
||||
if($language['code'] === $languageCode)
|
||||
{
|
||||
return $language['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|false if language preference could not be loaded
|
||||
*/
|
||||
static protected function getLanguageFromPreferences()
|
||||
{
|
||||
if ($language = Piwik_LanguagesManager_API::getInstance()->getLanguageForSession())
|
||||
{
|
||||
return $language;
|
||||
}
|
||||
|
||||
try {
|
||||
$currentUser = Piwik::getCurrentUserLogin();
|
||||
return Piwik_LanguagesManager_API::getInstance()->getLanguageForUser($currentUser);
|
||||
} catch(Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<span class="topBarElem" style="padding-right:70px">
|
||||
<span id="languageSelection" style="display:none;position:absolute">
|
||||
<form action="index.php?{if $currentModule != ''}module=LanguagesManager&{/if}action=saveLanguage" method="get">
|
||||
<select name="language">
|
||||
<option value="{$currentLanguageCode}">{$currentLanguageName}</option>
|
||||
<option href='misc/redirectToUrl.php?url=http://piwik.org/translations/'>{'LanguagesManager_AboutPiwikTranslations'|translate}</option>
|
||||
{foreach from=$languages item=language}
|
||||
<option value="{$language.code}">{$language.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<input type="submit" value="go" />
|
||||
</form>
|
||||
</span>
|
||||
|
||||
{literal}<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#languageSelection").fdd2div({CssClassName:"formDiv"});
|
||||
$("#languageSelection").show();
|
||||
$("#languageSelection ul").hide();
|
||||
});</script>
|
||||
{/literal}
|
||||
</span>
|
||||
Reference in New Issue
Block a user