Skip to content

Commit

Permalink
[Task] Make api accessible via http #3
Browse files Browse the repository at this point in the history
+ adds protocol setting
+ updates Index.html
  • Loading branch information
Sarah Rehbock committed May 1, 2016
1 parent b688842 commit 7a65527
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public function updateAction(array $piwik)
$settings = $this->configurationSource->load($configurationPath . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
$piwik['host'] = preg_replace("(^https?://)", "", $piwik['host']);
$settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.host', $piwik['host']);
$settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.protocol', $piwik['protocol']);
$settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.token_auth', $piwik['token_auth']);
if (array_key_exists('idSite', $piwik)) {
$settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.idSite', $piwik['idSite']);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Portachtzig/Neos/Piwik/Service/Reporting.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function callAPI($piwikMethod, $arguments = array())
}
}
// @todo force https here or throw error ?
$apiCallUrl = 'https://' . $this->settings['host'] . '/index.php?module=API&format=json&' . $params;
$apiCallUrl = $this->settings['protocol'] . '://' . $this->settings['host'] . '/index.php?module=API&format=json&' . $params;
$apiCallUrl .= '&idSite=' . $this->settings['idSite'] . '&token_auth=' . $this->settings['token_auth'];
$this->browser->setRequestEngine($this->browserRequestEngine);
$response = $this->browser->request($apiCallUrl);
Expand All @@ -97,7 +97,7 @@ public function getNodeStatistics($node = NULL, $controllerContext = NULL, $argu
}
}

$apiCallUrl = 'https://' . $this->settings['host'] . '/index.php?module=API&format=json' . $params;
$apiCallUrl = $this->settings['protocol'] . '://' . $this->settings['host'] . '/index.php?module=API&format=json' . $params;
$apiCallUrl .= '&pageUrl=' . urlencode($this->getLiveNodeUri($node, $controllerContext)->__toString());
$apiCallUrl .= '&idSite=' . $this->settings['idSite'] . '&token_auth=' . $this->settings['token_auth'];
$this->browser->setRequestEngine($this->browserRequestEngine);
Expand Down
1 change: 1 addition & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Portachtzig:
Neos:
Piwik:
host: ''
protocol: 'https'
token_auth: ''
idSite: ''
TYPO3:
Expand Down
88 changes: 55 additions & 33 deletions Resources/Private/Templates/Module/Piwik/Index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
<f:layout name="Default" />

<f:section name="Title">

<p>
<img src="{piwikHost.headerLogo.value}" alt="Piwik Logo">
<br><br>
<h1>
Piwik Host Information
</h1>
<br><br>
<h1>Piwik Host Information</h1>
<br>
</p>
</f:section>
<f:section name="Content">

<f:flashMessages />
<div class="neos-row-fluid">
<div class="neos-span4">
Expand All @@ -32,9 +26,6 @@ <h1>
</tr>
</table>
</div>
<div class="neos-span7 neos-offset1">

</div>
</div>
<f:form action="update" name="piwik" object="{settings}">
<fieldset>
Expand All @@ -43,17 +34,51 @@ <h1>
<br>
<h1>Configuration</h1>
<br>

<div class="neos-control-group">
<label class="neos-control-label" for="host">Host</label>

<div class="neos-controls">
<f:form.textfield property="host" id="host" class="neos-span12" required="true" />
</div>


</div>
<div class="neos-controls">
<br>
<label class="neos-control-label" for="protocol">Protocol </label>
<label class="neos-radio neos-inline" for="https_protocol">
<f:form.radio property="protocol" id="https_protocol" value="https"
checked="{settings.protocol} == 'https'"/> https
<span></span>
</label>
<label class="neos-radio neos-inline " for="http_protocol" >
<f:form.radio property="protocol" id="http_protocol"
value="http" checked="{settings.protocol} == 'http'" /> http
<span></span>
</label>
<span data-toggle="modal" class="neos-inline neos-button neos-button-small"
href="#protocol-modal">?</span>
</div>
<div class="neos-hide" id="protocol-modal">
<div class="neos-modal">
<div class="neos-modal-header">
<button type="button" class="neos-close neos-button" data-dismiss="modal"></button>
<div class="neos-header">Warning</div>
</div>
<div class="neos-subheader">
<p>
Be aware that using <b>HTTP</b> for communication with your Piwik host
<b>{settings.host}</b> will result in your super user's auth_token being transmitted as an unencrypted URL parameter!
<br>
<br>
</p>
</div>
<div class="neos-modal-footer">
<a href="#" class="neos-button" data-dismiss="modal">OK</a>
</div>
</div>
<div class="neos-modal-backdrop neos-in"></div>
</div>

<div class="neos-control-group">
<br>
<label class="neos-control-label" for="token_auth">Token</label>
<div class="neos-controls">
<f:form.textfield property="token_auth" id="token_auth" class="neos-span12" required="true" />
Expand All @@ -64,24 +89,22 @@ <h1>Configuration</h1>
</small>
</p>
</div>

<f:if condition="{piwikError} != 1">
<div class="neos-control-group">
<label class="neos-control-label" for="idSite">Piwik Site to use for this Neos installation:</label>
<div class="neos-controls">

<select name="moduleArguments[piwik][idSite]" id="idSite" class="neos-span12" >

<f:for each="{piwikHost.sites}" as="site">

<option value="{site.idsite}" {f:if(condition:'{settings.idSite} == {site.idsite}',then:'selected="selected"')}>{site.name}</option>

</f:for>

</select>

<f:if condition="{settings.token_auth}">
<f:if condition="{piwikError} != 1">
<div class="neos-control-group">
<br>
<label class="neos-control-label" for="idSite">Piwik Site to use for this Neos installation:</label>
<div class="neos-controls">
<select name="moduleArguments[piwik][idSite]" id="idSite" class="neos-span12" >
<f:for each="{piwikHost.sites}" as="site">
<option value="{site.idsite}"
{f:if(condition:'{settings.idSite} == {site.idsite}',then:'selected="selected"')}>
{site.name}</option>
</f:for>
</select>
</div>
</div>
</div>
</f:if>
</f:if>
</fieldset>

Expand Down Expand Up @@ -120,6 +143,5 @@ <h1>Configuration</h1>
</div>
</fieldset>
</f:form>

<f:form action="index" id="postHelper" method="post"></f:form>
</f:section>

0 comments on commit 7a65527

Please sign in to comment.