diff options
-rwxr-xr-x | inc/poche/Database.class.php | 8 | ||||
-rwxr-xr-x | inc/poche/Poche.class.php | 11 | ||||
-rw-r--r-- | inc/poche/global.inc.php | 2 | ||||
-rw-r--r-- | themes/baggy/_menu.twig | 3 | ||||
-rw-r--r-- | themes/baggy/_search-form.twig | 21 | ||||
-rwxr-xr-x | themes/baggy/css/main.css | 50 | ||||
-rw-r--r-- | themes/default/_menu.twig | 2 | ||||
-rw-r--r-- | themes/default/_search-form.twig | 23 | ||||
-rwxr-xr-x | themes/default/home.twig | 3 |
9 files changed, 119 insertions, 4 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 5b51b507..6aad16c1 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -388,6 +388,14 @@ class Database { | |||
388 | public function getLastId($column = '') { | 388 | public function getLastId($column = '') { |
389 | return $this->getHandle()->lastInsertId($column); | 389 | return $this->getHandle()->lastInsertId($column); |
390 | } | 390 | } |
391 | |||
392 | public function search($term){ | ||
393 | $search = '%'.$term.'%'; | ||
394 | $query = $this->getHandle()->prepare("SELECT * FROM entries WHERE content LIKE ?"); | ||
395 | $query->execute(array($search)); | ||
396 | $entries = $query->fetchAll(); | ||
397 | return $entries; | ||
398 | } | ||
391 | 399 | ||
392 | public function retrieveAllTags($user_id, $term = null) { | 400 | public function retrieveAllTags($user_id, $term = null) { |
393 | $sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags | 401 | $sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags |
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index b1143d0b..c7aa71e8 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -603,6 +603,14 @@ class Poche | |||
603 | 'tags' => $tags, | 603 | 'tags' => $tags, |
604 | ); | 604 | ); |
605 | break; | 605 | break; |
606 | |||
607 | case 'search': | ||
608 | if (isset($_GET['search'])){ | ||
609 | $search = $_GET['search']; | ||
610 | $tpl_vars['entries'] = $this->store->search($search); | ||
611 | $tpl_vars['nb_results'] = count($tpl_vars['entries']); | ||
612 | } | ||
613 | break; | ||
606 | case 'view': | 614 | case 'view': |
607 | $entry = $this->store->retrieveOneById($id, $this->user->getId()); | 615 | $entry = $this->store->retrieveOneById($id, $this->user->getId()); |
608 | if ($entry != NULL) { | 616 | if ($entry != NULL) { |
@@ -772,8 +780,7 @@ class Poche | |||
772 | $this->emptyCache(); | 780 | $this->emptyCache(); |
773 | 781 | ||
774 | Tools::redirect('?view=config'); | 782 | Tools::redirect('?view=config'); |
775 | } | 783 | } |
776 | |||
777 | /** | 784 | /** |
778 | * get credentials from differents sources | 785 | * get credentials from differents sources |
779 | * it redirects the user to the $referer link | 786 | * it redirects the user to the $referer link |
diff --git a/inc/poche/global.inc.php b/inc/poche/global.inc.php index d22b0588..15091387 100644 --- a/inc/poche/global.inc.php +++ b/inc/poche/global.inc.php | |||
@@ -38,7 +38,7 @@ if (! file_exists(ROOT . '/vendor/autoload.php')) { | |||
38 | require_once ROOT . '/vendor/autoload.php'; | 38 | require_once ROOT . '/vendor/autoload.php'; |
39 | } | 39 | } |
40 | 40 | ||
41 | # system configuration; database credentials et cetera | 41 | # system configuration; database credentials et caetera |
42 | if (! file_exists(INCLUDES . '/poche/config.inc.php')) { | 42 | if (! file_exists(INCLUDES . '/poche/config.inc.php')) { |
43 | Poche::$configFileAvailable = false; | 43 | Poche::$configFileAvailable = false; |
44 | } else { | 44 | } else { |
diff --git a/themes/baggy/_menu.twig b/themes/baggy/_menu.twig index 5226728b..f1b75cd5 100644 --- a/themes/baggy/_menu.twig +++ b/themes/baggy/_menu.twig | |||
@@ -7,6 +7,9 @@ | |||
7 | <li style="position: relative;"><a href="javascript: void(null);" id="bagit">{% trans "save a link" %}</a> | 7 | <li style="position: relative;"><a href="javascript: void(null);" id="bagit">{% trans "save a link" %}</a> |
8 | {% include '_pocheit-form.twig' %} | 8 | {% include '_pocheit-form.twig' %} |
9 | </li> | 9 | </li> |
10 | <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans "search" %}</a> | ||
11 | {% include '_search-form.twig' %} | ||
12 | </li> | ||
10 | <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li> | 13 | <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li> |
11 | <li><a class="icon icon-power" href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li> | 14 | <li><a class="icon icon-power" href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li> |
12 | </ul> | 15 | </ul> |
diff --git a/themes/baggy/_search-form.twig b/themes/baggy/_search-form.twig new file mode 100644 index 00000000..1fd4154e --- /dev/null +++ b/themes/baggy/_search-form.twig | |||
@@ -0,0 +1,21 @@ | |||
1 | <div id="search-form" class="messages info"> | ||
2 | <form method="get" action="index.php"> | ||
3 | <input type="hidden" name="view" value="search"></input> | ||
4 | <label><a href="javascript: void(null);" id="search-form-close">X</a>{% trans "Search" %}</label> : <input type="text" name="search" /> | ||
5 | <input id="submit-search" type="submit" value="{% trans "Search" %} !"></input> | ||
6 | </form> | ||
7 | </div> | ||
8 | <script type="text/javascript"> | ||
9 | $(document).ready(function() { | ||
10 | |||
11 | $("#search-form").hide(); | ||
12 | |||
13 | $("#search").click(function(){ | ||
14 | $("#search-form").toggle(); | ||
15 | $("#search").toggleClass("current"); | ||
16 | $("#search-arrow").toggleClass("arrow-down"); | ||
17 | }); | ||
18 | |||
19 | |||
20 | }); | ||
21 | </script> \ No newline at end of file | ||
diff --git a/themes/baggy/css/main.css b/themes/baggy/css/main.css index 61e0b47e..6e328ba1 100755 --- a/themes/baggy/css/main.css +++ b/themes/baggy/css/main.css | |||
@@ -613,6 +613,56 @@ a#bagit-form-close:hover { | |||
613 | } | 613 | } |
614 | 614 | ||
615 | /* ========================================================================== | 615 | /* ========================================================================== |
616 | 2.2 = "search for articles" popup div related styles | ||
617 | ========================================================================== */ | ||
618 | #search-form { | ||
619 | background: rgba(0,0,0,0.5); | ||
620 | position: absolute; | ||
621 | top: 0; | ||
622 | left: 10em; | ||
623 | z-index: 20; | ||
624 | height: 100%; | ||
625 | width: 100%; | ||
626 | margin: 0; | ||
627 | margin-top: -30%; | ||
628 | padding: 2em; | ||
629 | display: none; | ||
630 | border-left: 1px #EEE solid; | ||
631 | } | ||
632 | |||
633 | #search-form form { | ||
634 | background: #FFF; | ||
635 | position: absolute; | ||
636 | top: 0; | ||
637 | left: 0; | ||
638 | z-index: 20; | ||
639 | border: 10px solid #000; | ||
640 | width: 400px; | ||
641 | height: 200px; | ||
642 | /* margin: -150px 0 0 -300px; */ | ||
643 | padding: 2em; | ||
644 | } | ||
645 | |||
646 | a#search-form-close { | ||
647 | background: #000; | ||
648 | color: #FFF; | ||
649 | padding: 0.2em 0.5em; | ||
650 | text-decoration: none; | ||
651 | display: inline-block; | ||
652 | float: right; | ||
653 | font-size: 1.2em; | ||
654 | } | ||
655 | a#search-form-close:hover { | ||
656 | background: #999; | ||
657 | color: #000; | ||
658 | } | ||
659 | |||
660 | #submit-search{ | ||
661 | margin-left: 4em; | ||
662 | margin-top:1em; | ||
663 | } | ||
664 | |||
665 | /* ========================================================================== | ||
616 | 3 = Pictos | 666 | 3 = Pictos |
617 | ========================================================================== */ | 667 | ========================================================================== */ |
618 | 668 | ||
diff --git a/themes/default/_menu.twig b/themes/default/_menu.twig index 55583b3d..0e7dd0a7 100644 --- a/themes/default/_menu.twig +++ b/themes/default/_menu.twig | |||
@@ -4,8 +4,10 @@ | |||
4 | <li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li> | 4 | <li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li> |
5 | <li><a href="./?view=tags" {% if view == 'tags' %}class="current"{% endif %}>{% trans "tags" %}</a></li> | 5 | <li><a href="./?view=tags" {% if view == 'tags' %}class="current"{% endif %}>{% trans "tags" %}</a></li> |
6 | <li><a href="javascript: void(null);" id="pocheit">{% trans "save a link" %}</a><span id="pocheit-arrow"></span></li> | 6 | <li><a href="javascript: void(null);" id="pocheit">{% trans "save a link" %}</a><span id="pocheit-arrow"></span></li> |
7 | <li><a href="javascript: void(null);" id="search">{% trans "search" %}</a><span id="search-arrow"></span></li> | ||
7 | <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li> | 8 | <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li> |
8 | <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li> | 9 | <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li> |
9 | </ul> | 10 | </ul> |
10 | {% include '_pocheit-form.twig' %} | 11 | {% include '_pocheit-form.twig' %} |
12 | {% include '_search-form.twig' %} | ||
11 | 13 | ||
diff --git a/themes/default/_search-form.twig b/themes/default/_search-form.twig new file mode 100644 index 00000000..74f420d0 --- /dev/null +++ b/themes/default/_search-form.twig | |||
@@ -0,0 +1,23 @@ | |||
1 | <div id="search-form" class="messages info"> | ||
2 | <form method="get" action="index.php"> | ||
3 | <p> | ||
4 | <input type="hidden" name="view" value="search"></input> | ||
5 | <label>{% trans "Search" %}</label> : <input type="text" placeholder="{% trans "Enter your search here" %}" name="search" /> | ||
6 | <input type="submit" value="{% trans "Search" %} !"></input> | ||
7 | </p> | ||
8 | </form> | ||
9 | </div> | ||
10 | <script type="text/javascript"> | ||
11 | $(document).ready(function() { | ||
12 | |||
13 | $("#search-form").hide(); | ||
14 | |||
15 | $("#search").click(function(){ | ||
16 | $("#search-form").toggle(); | ||
17 | $("#search").toggleClass("current"); | ||
18 | $("#search-arrow").toggleClass("arrow-down"); | ||
19 | }); | ||
20 | |||
21 | |||
22 | }); | ||
23 | </script> \ No newline at end of file | ||
diff --git a/themes/default/home.twig b/themes/default/home.twig index bd5fc2d6..b6185df1 100755 --- a/themes/default/home.twig +++ b/themes/default/home.twig | |||
@@ -12,7 +12,8 @@ | |||
12 | {% include '_menu.twig' %} | 12 | {% include '_menu.twig' %} |
13 | {% endblock %} | 13 | {% endblock %} |
14 | {% block precontent %} | 14 | {% block precontent %} |
15 | {% include '_sorting.twig' %} | 15 | |
16 | {% include '_sorting.twig' %} | ||
16 | {% endblock %} | 17 | {% endblock %} |
17 | {% block content %} | 18 | {% block content %} |
18 | {% if tag %} | 19 | {% if tag %} |