Skip to content

Commit

Permalink
Update templates to remove deprecated addScript function. Format files
Browse files Browse the repository at this point in the history
  • Loading branch information
te-online committed Apr 7, 2023
1 parent 9230cd4 commit 4bf8aa7
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 66 deletions.
17 changes: 11 additions & 6 deletions templates/clients.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?php
script('timemanager', 'timemanager');

use \OCP\Util;

Util::addScript('timemanager', 'timemanager');
style('timemanager', 'timemanager');

$urlGenerator = \OC::$server->getURLGenerator();
$l = \OC::$server->getL10N('timemanager');
$l = Util::getL10N('timemanager');
?>

<?php print_unescaped( $this->inc( 'partials/navigation' ) ); ?>
<?php print_unescaped($this->inc('partials/navigation')); ?>

<div id="app-content">
<div class="container">
Expand All @@ -21,8 +25,8 @@
<h2 class="list-title"><?php p($l->t('Clients')); ?></h2>
<span data-svelte="ClientEditorDialog.svelte"></span>
<span data-store="<?php p($_['store']); ?>"></span>
<?php if(count($_['clients']) > 0) {
foreach($_['clients'] as $client) { ?>
<?php if (count($_['clients']) > 0) {
foreach ($_['clients'] as $client) { ?>
<div class="tm_item-row with-link">
<a class="timemanager-pjax-link" href="<?php echo $urlGenerator->linkToRoute('timemanager.page.projects'); ?>?client=<?php echo $client->getUuid(); ?>">
<h3><?php p($client->getName()); ?></h3>
Expand All @@ -40,7 +44,8 @@
</div>
</a>
</div>
<?php } } else { ?>
<?php }
} else { ?>
<div class="tm_item-row">
<h3><?php p($l->t("You don't have any clients, yet. Get started by clicking “Add client”.")); ?></h3>
</div>
Expand Down
11 changes: 8 additions & 3 deletions templates/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php
script('timemanager', 'timemanager');

use \OCP\Util;

Util::addScript('timemanager', 'timemanager');
style('timemanager', 'timemanager');

$l = Util::getL10N('timemanager');

?>

<?php print_unescaped( $this->inc( 'partials/navigation' ) ); ?>
<?php print_unescaped($this->inc('partials/navigation')); ?>

<div id="app-content">
<div class="container">
Expand All @@ -14,7 +19,7 @@
<span data-store="<?php p($_['store']); ?>"></span>
</section>

<?php print_unescaped( $this->inc( 'partials/latest' ) ); ?>
<?php print_unescaped($this->inc('partials/latest')); ?>

<section class="section statistics" data-svelte="Statistics.svelte"></section>
</div>
Expand Down
7 changes: 5 additions & 2 deletions templates/partials/latest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
$urlGenerator = \OC::$server->getURLGenerator();
$l = \OC::$server->getL10N('timemanager');

use \OCP\Util;

$urlGenerator = \OC::$server->getURLGenerator();
$l = Util::getL10N('timemanager');
?>

<h2 class="latest-headline">
Expand Down
5 changes: 4 additions & 1 deletion templates/partials/navigation.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

use \OCP\Util;

$urlGenerator = \OC::$server->getURLGenerator();
$l = \OC::$server->getL10N('timemanager');
$l = Util::getL10N('timemanager');
?>

<div id="app-navigation">
Expand Down
18 changes: 11 additions & 7 deletions templates/partials/sharestatus.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php
/**
* Displays a short in-line version of the sharing status of an entity,
* provided it has the `sharees` array and `sharer` property set.
* Expects the full entity passed in as `entity` template variable
*/

/**
* Displays a short in-line version of the sharing status of an entity,
* provided it has the `sharees` array and `sharer` property set.
* Expects the full entity passed in as `entity` template variable
*/
?>
<?php
$urlGenerator = \OC::$server->getURLGenerator();
$l = \OC::$server->getL10N('timemanager');

use \OCP\Util;

$urlGenerator = \OC::$server->getURLGenerator();
$l = Util::getL10N('timemanager');
?>
<?php if (isset($_['entity']->sharees) && count($_['entity']->sharees) > 0) { ?>
&nbsp;&middot;&nbsp;
Expand Down
38 changes: 22 additions & 16 deletions templates/projects.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?php
script('timemanager', 'timemanager');

use \OCP\Util;

Util::addScript('timemanager', 'timemanager');
style('timemanager', 'timemanager');

$urlGenerator = \OC::$server->getURLGenerator();
$l = \OC::$server->getL10N('timemanager');
$l = Util::getL10N('timemanager');
?>

<?php print_unescaped( $this->inc( 'partials/navigation' ) ); ?>
<?php print_unescaped($this->inc('partials/navigation')); ?>

<div id="app-content">
<div class="container">
<?php if($_['client']) { ?>
<?php if ($_['client']) { ?>
<div class="section">
<div class="tm_object-details">
<h2>
Expand All @@ -33,14 +37,14 @@
<?php p($_['client']->getPostcode()); ?> <?php p($_['client']->getCity()); ?>
</div>
<?php } ?>
<?php if($_['client']) { ?>
<?php if ($_['client']) { ?>
<div class="tm_object-details-item">
<span data-svelte="ShareStatus.svelte"></span>
<span data-svelte-hide="ShareStatus.svelte">
<?php print_unescaped($_['templates']['ShareStatus.svelte']); ?>
</span>
</div>
<?php if($_['canEdit']) { ?>
<?php if ($_['canEdit']) { ?>
<span data-svelte="ClientEditorDialog.svelte"></span>
<span data-svelte="DeleteButton.svelte"></span>
<span data-svelte-hide="DeleteButton.svelte">
Expand All @@ -53,7 +57,7 @@
<?php } ?>
<?php } ?>
</div>
<?php if($_['canEdit']) { ?>
<?php if ($_['canEdit']) { ?>
<div class="tm_add" data-svelte-hide="ProjectEditor.svelte">
<div id="new-item" class="tm_new-item">
<?php print_unescaped($_['templates']['ProjectEditor.svelte']); ?>
Expand All @@ -67,8 +71,8 @@
<div class="tm_item-list space-bottom">
<h2 class="list-title"><?php p($l->t('All projects')); ?></h2>
<?php if (count($_['projects']) > 0) {
foreach ($_['projects'] as $project) {
?>
foreach ($_['projects'] as $project) {
?>
<div class="tm_item-row with-link">
<a class="timemanager-pjax-link" href="<?php echo $urlGenerator->linkToRoute('timemanager.page.tasks'); ?>?project=<?php echo $project->getUuid(); ?>">
<h3><em><?php p($project->client->getName()); ?></em> › <?php p($project->getName()); ?></h3>
Expand All @@ -79,19 +83,20 @@
</div>
</a>
</div>
<?php } } ?>
<?php }
} ?>
</div>
<?php } ?>
<div class="tm_item-list">
<h2 class="list-title"><?php p($l->t('Projects')); ?></h2>
<?php if($_['client'] && $_['canEdit']) { ?>
<?php if ($_['client'] && $_['canEdit']) { ?>
<span data-svelte="ProjectEditorDialog.svelte"></span>
<?php } ?>
<span data-store="<?php p($_['store']); ?>"></span>
<?php if (!$_['client']) { ?>
<p><?php p($l->t('Select a client to show projects for')); ?></p>
<form action="" method="get">
<?php if (count($_['clients']) > 0 ) { ?>
<?php if (count($_['clients']) > 0) { ?>
<select name="client">
<?php foreach ($_['clients'] as $client) { ?>
<option value="<?php p($client->getUuid()); ?>"><?php p($client->getName()); ?></option>
Expand All @@ -104,9 +109,9 @@
</form>
<p><em><?php p($l->t('Select a client first to show projects for this client.')); ?></em></p>
<?php } else { ?>
<?php if(count($_['projects']) > 0) {
foreach($_['projects'] as $project) {
?>
<?php if (count($_['projects']) > 0) {
foreach ($_['projects'] as $project) {
?>
<div class="tm_item-row with-link">
<a class="timemanager-pjax-link" href="<?php echo $urlGenerator->linkToRoute('timemanager.page.tasks'); ?>?project=<?php echo $project->getUuid(); ?>">
<h3><?php p($project->getName()); ?></h3>
Expand All @@ -115,7 +120,8 @@
</div>
</a>
</div>
<?php } } else { ?>
<?php }
} else { ?>
<div class="tm_item-row">
<h3><?php p($l->t("You don't have any projects, yet. Try adding one by clicking “Add project”.")); ?></h3>
</div>
Expand Down
9 changes: 6 additions & 3 deletions templates/reports.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php
script("timemanager", "timemanager");
style("timemanager", "timemanager");

use \OCP\Util;

Util::addScript('timemanager', 'timemanager');
style('timemanager', 'timemanager');

$urlGenerator = \OC::$server->getURLGenerator();
$l = \OC::$server->getL10N("timemanager");
$l = Util::getL10N('timemanager');
?>

<?php print_unescaped($this->inc("partials/navigation")); ?>
Expand Down
38 changes: 22 additions & 16 deletions templates/tasks.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?php
script('timemanager', 'timemanager');

use \OCP\Util;

Util::addScript('timemanager', 'timemanager');
style('timemanager', 'timemanager');

$urlGenerator = \OC::$server->getURLGenerator();
$l = \OC::$server->getL10N('timemanager');
$l = Util::getL10N('timemanager');
?>

<?php print_unescaped( $this->inc( 'partials/navigation' ) ); ?>
<?php print_unescaped($this->inc('partials/navigation')); ?>

<div id="app-content">
<div class="container">
<?php if($_['client'] && $_['project']) { ?>
<?php if ($_['client'] && $_['project']) { ?>
<div class="section">
<div class="tm_object-details">
<h2>
Expand All @@ -32,15 +36,15 @@
<?php print_unescaped($_['templates']['ShareStatus.svelte']); ?>
</span>
</div>
<?php if($_['project'] && $_['canEdit']) { ?>
<?php if ($_['project'] && $_['canEdit']) { ?>
<span data-svelte="ProjectEditorDialog.svelte"></span>
<span data-svelte="DeleteButton.svelte"></span>
<span data-svelte-hide="DeleteButton.svelte">
<?php print_unescaped($_['templates']['DeleteButton.svelte']); ?>
</span>
<?php } ?>
</div>
<?php if($_['canEdit']) { ?>
<?php if ($_['canEdit']) { ?>
<div class="tm_add" data-svelte-hide="TaskEditor.svelte">
<div id="new-item" class="tm_new-item">
<?php print_unescaped($_['templates']['TaskEditor.svelte']); ?>
Expand All @@ -54,8 +58,8 @@
<div class="tm_item-list space-bottom">
<h2 class="list-title"><?php p($l->t('All tasks')); ?></h2>
<?php if (count($_['tasks']) > 0) {
foreach ($_['tasks'] as $task) {
?>
foreach ($_['tasks'] as $task) {
?>
<div class="tm_item-row with-link">
<a class="timemanager-pjax-link" href="<?php echo $urlGenerator->linkToRoute('timemanager.page.times'); ?>?task=<?php echo $task->getUuid(); ?>">
<h3><em><?php p($task->client->getName()); ?></em> › <em><?php p($task->project->getName()); ?></em> › <?php p($task->getName()); ?></h3>
Expand All @@ -65,29 +69,30 @@
</div>
</a>
</div>
<?php } } ?>
<?php }
} ?>
</div>
<?php } ?>
<div class="tm_item-list">
<h2 class="list-title"><?php p($l->t('Tasks')); ?></h2>
<?php if($_['project'] && $_['canEdit']) { ?>
<?php if ($_['project'] && $_['canEdit']) { ?>
<span data-svelte="TaskEditorDialog.svelte"></span>
<?php } ?>
<span data-store="<?php p($_['store']); ?>"></span>
<?php if (!$_['project']) { ?>
<p><?php p($l->t('Select a project to show tasks for')); ?></p>
<form action="" method="get">
<?php if (count($_['projects']) > 0 ) { ?>
<?php if (count($_['projects']) > 0) { ?>
<select name="project">
<?php foreach ($_['projects'] as $project) {
// Look up client for project
$client = array_reduce($_['clients'], function ($carry, $oneClient) use(&$project) {
$client = array_reduce($_['clients'], function ($carry, $oneClient) use (&$project) {
if ($oneClient->getUuid() === $project->getClientUuid()) {
$carry = $oneClient;
}
return $carry;
});
?>
?>
<option value="<?php p($project->getUuid()); ?>"><?php p($client->getName() . '' . $project->getName()); ?></option>
<?php } ?>
</select>
Expand All @@ -98,8 +103,8 @@
</form>
<p><em><?php p($l->t('Select a project first to show the tasks for this project.')); ?></em></p>
<?php } else { ?>
<?php if(count($_['tasks']) > 0) {
foreach($_['tasks'] as $task) { ?>
<?php if (count($_['tasks']) > 0) {
foreach ($_['tasks'] as $task) { ?>
<div class="tm_item-row with-link">
<a class="timemanager-pjax-link" href="<?php echo $urlGenerator->linkToRoute('timemanager.page.times'); ?>?task=<?php echo $task->getUuid(); ?>">
<h3><?php p($task->getName()); ?></h3>
Expand All @@ -108,7 +113,8 @@
</div>
</a>
</div>
<?php } } else { ?>
<?php }
} else { ?>
<div class="tm_item-row">
<h3><?php p($l->t("You don't have any tasks, yet. Try adding one by clicking “Add task”.")); ?></h3>
</div>
Expand Down
Loading

0 comments on commit 4bf8aa7

Please sign in to comment.