-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 063c0d9
Showing
9 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Leantime\Plugins\MotivationalQuotes\Controllers; | ||
|
||
use Leantime\Core\Controller; | ||
|
||
/** | ||
* Settings Controller for Motivational Quotes Plugin | ||
* | ||
* @package leantime | ||
* @subpackage plugins | ||
*/ | ||
class Settings extends Controller | ||
{ | ||
/** | ||
* init | ||
* | ||
* @return void | ||
*/ | ||
public function init(): void | ||
{ | ||
} | ||
|
||
/** | ||
* get | ||
* | ||
* @return void | ||
*/ | ||
public function get(): void | ||
{ | ||
$this->tpl->display("motivationalQuotes.settings"); | ||
} | ||
|
||
/** | ||
* post | ||
* | ||
* @param array $params | ||
* @return void | ||
*/ | ||
public function post(array $params): void | ||
{ | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Leantime\Plugins\MotivationalQuotes\Models; | ||
|
||
/** | ||
* quote model | ||
* | ||
* @package Leantime\Plugins\MotivationalQuotes\Models | ||
*/ | ||
class Quote | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public string $author; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public string $quote; | ||
|
||
/** | ||
* __construct | ||
* | ||
* @param string $quote | ||
* @param string $author | ||
* @return self | ||
*/ | ||
public function __construct(string $quote = "", string $author = "") | ||
{ | ||
$this->author = $author; | ||
$this->quote = $quote; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Leantime\Plugins\MotivationalQuotes\Repositories; | ||
|
||
use Leantime\Plugins\MotivationalQuotes\Models\Quote; | ||
|
||
/** | ||
* motivationalQuotes Repository | ||
*/ | ||
class MotivationalQuotes | ||
{ | ||
/** | ||
* constructor | ||
* | ||
* @return self | ||
*/ | ||
public function __construct() | ||
{ | ||
//Get DB Instance | ||
//$this->db = app()->make(\Leantime\Core\Db::class); | ||
} | ||
|
||
/** | ||
* getAllQuotes | ||
* | ||
* @return Quote[] | ||
*/ | ||
public function getAllQuotes(): array | ||
{ | ||
$quotes = [ | ||
"To live is the rarest thing in the world. Most people exist, that is all." => "Oscar Wilde", | ||
"You cannot find peace by avoiding life" => "Virginia Woolf", | ||
"The strongest principle of growth lies in the human choice" => "George Eliot", | ||
"Focus more on your desire than on your doubt, and the dream will take care of itself." => "Mark Twain", | ||
"We have to continually be jumping off cliffs and developing our wings on the way down." => "Kurt Vonnegut", | ||
"Don't bend; don't water it down; don't try to make it logical; don't edit your own soul according to the fashion. Rather, follow your most intense obsessions mercilessly." => "Franz Kafka", | ||
"Keep away from people who try to belittle your ambitions. Small people always do that, but the really great make you feel that you, too, can become great." => "Mark Twain", | ||
"Trust our heart if the seas catch fire, live by love though the stars walk backwards." => "E. E. Cummings", | ||
"One day I will find the right words, and they will be simple." => "Jack Kerouac", | ||
"I can be changed by what happens to me. But I refuse to be reduced by it." => "Maya Angelou", | ||
"The most common way people give up their power is by thinking they don't have any." => "Alice Walker", | ||
"I want to taste and glory in each day, and never be afraid to experience pain." => "Sylvia Plath", | ||
"If I waited for perfection, I would never write a word." => "Margaret Atwood", | ||
"How wonderful it is that nobody need wait a single moment before starting to improve the world." => "Anne Frank", | ||
"We are what we repeatedly do. Excellence, then, is not an act, but a habit." => "Aristotle", | ||
]; | ||
|
||
//Results could be fetched from the db here. | ||
$quotes = array_map( | ||
fn ($quote, $author) => app()->make( | ||
Quote::class, | ||
['quote' => $quote, 'author' => $author] | ||
), | ||
array_keys($quotes), | ||
array_values($quotes) | ||
); | ||
|
||
return $quotes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Leantime\Plugins\MotivationalQuotes\Services; | ||
|
||
use Leantime\Plugins\MotivationalQuotes\Repositories\MotivationalQuotes as MotivationalQuotesRepository; | ||
use Leantime\Plugins\MotivationalQuotes\Models\Quote as QuoteModel; | ||
|
||
/** | ||
* motivational quotes service | ||
*/ | ||
class MotivationalQuotes | ||
{ | ||
/** | ||
* constructor | ||
* | ||
* @param MotivationalQuotesRepository $quotesRepo | ||
* @return self | ||
*/ | ||
public function __construct(MotivationalQuotesRepository $quotesRepo) | ||
{ | ||
$this->quotesRepo = $quotesRepo; | ||
} | ||
|
||
/** | ||
* get random quote | ||
* | ||
* @return QuoteModel | ||
*/ | ||
public function getRandomQuote(): QuoteModel | ||
{ | ||
$availableQuotes = $this->quotesRepo->getAllQuotes(); | ||
|
||
$numberOfQuotes = count($availableQuotes) - 1; | ||
$randomNumber = rand(0, $numberOfQuotes); | ||
|
||
return $availableQuotes[$randomNumber]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
<div class="pageheader"> | ||
<div class="pageicon"><span class="fa fa-book"></span></div> | ||
<div class="pagetitle"> | ||
<h1>Example plugin settings page</h1> | ||
</div> | ||
</div> | ||
|
||
<div class="maincontent"> | ||
|
||
<div class="maincontentinner" style="text-align: center;"> | ||
<h1>Actually, there are not settings for this plugin.</h1><br /> | ||
<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> | ||
</div> | ||
</div> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "leantime/motivationalquotes", | ||
"description": "Displays a random quote on the welcome page", | ||
"version": "0.1", | ||
"screenshot": "/images/screenshot.png", | ||
"authors": [ | ||
{ | ||
"name": "Leantime", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"homepage": "https://leantime.io", | ||
"type": "leantime-plugin", | ||
"keywords": [ | ||
"quotes", | ||
"inspirational" | ||
], | ||
"license": "MIT", | ||
"require": { | ||
"leantime/leantime": "2.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
/** | ||
* MotivationalQuotes | ||
* | ||
* Plugin to greet you with a motivation quote on your home page. | ||
* Example plugin to show basic plugin structure. | ||
* | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/** | ||
* MotivationalQuotes | ||
* | ||
* Register Events here | ||
*/ | ||
|
||
\Leantime\Core\Events::add_event_listener( | ||
//Register event listener | ||
"core.template.tpl.dashboard.home.afterWelcomeMessage", | ||
//Create function for the event | ||
function ($payload) { | ||
// code here | ||
$motivationalQuotesSvc = app()->make(\Leantime\Plugins\MotivationalQuotes\Services\MotivationalQuotes::class); | ||
$randomQuote = $motivationalQuotesSvc->getRandomQuote(); | ||
echo"<div class='motivationalQuote' style='margin-bottom:20px;'><br />"; | ||
echo "<p>Quote of the day:</p>"; | ||
echo "<p style='font-style: italic; font-weight:normal;'><i class='fa-solid fa-quote-left'></i> " . $randomQuote->quote . "</p>"; | ||
echo "<small>- " . $randomQuote->author . "</small></div>"; | ||
}, | ||
5 | ||
); |