Exemple #1
0
<?php

/* NOT USED*/
session_start();
if (!$_SESSION['logged']) {
    header("Location: ../login.php");
}
require_once '../init.php';
require_once '../lib/dao/entryDAO.php';
$id_entry = $_REQUEST['id_entry'];
if (!$id_entry) {
    throw Exception("No id_entry specified !");
}
$entryDAO = new EntryDAO();
$entry = $entryDAO->get($id_entry);
/*foreach($entry as $i => $field){
	$entry[$i] = htmlspecialchars($field, ENT_QUOTES);
}*/
$tags = $entry->getTags();
if ($tags) {
    $entry->setTags(implode(' ', $tags));
}
echo json_encode($entry);
/*
$entry = $db->getEntry($id_entry);
foreach($entry as $i => $field){
	$entry[$i] = htmlspecialchars($field, ENT_QUOTES);
}
$tags = $db->getEntryTags($id_entry);
if ($tags){
	$entry['tags'] = implode(' ', $tags);//_array);
Exemple #2
0
<?php

session_start();
if (!$_SESSION['logged']) {
    echo "<script type='text/javascript'>window.location.replace('login.php');</script>";
    exit;
}
require_once "../init.php";
require_once "../lib/dao/entryDAO.php";
$id_entry = $_POST['id'];
$entryDAO = new EntryDAO($db);
$entry = $entryDAO->delete($id_entry);
<?php

session_start();
if (!$_SESSION['logged']) {
    echo "<script type='text/javascript'>window.location.replace('login.php');</script>";
    exit;
}
require_once "../init.php";
require_once "../lib/dao/entryDAO.php";
if (isset($_REQUEST["id_entry"]) && $_REQUEST["id_entry"]) {
    $entryDAO = new EntryDAO($db);
    $entry = $entryDAO->get($_REQUEST["id_entry"]);
} else {
    $entry = new Entry();
}
include "../lib/view/entryEditView.php";
?>
<!--  
<div class='editForm'>
	<form>
		<div class="edit_line">
			<label for="entry_name" class="label_edit">Name </label>
			<br />
			<input name="entry_name"  value="<?php 
echo $entry->getName();
?>
" />
		</div>
		<div class="edit_line">
			<label for="entry_url" class="label_edit">Url </label>
			<br />
Exemple #4
0
<?php

session_start();
if (!isset($_SESSION['logged']) || !$_SESSION['logged']) {
    header("Location: login.php");
    exit;
}
require_once 'init.php';
require_once 'lib/dao/memoDAO.php';
require_once 'lib/dao/entryDAO.php';
require_once 'lib/dao/tagDAO.php';
// retrieve memo from db and remove slashes that were added when inserting into db
$memoDAO = new MemoDAO($db);
$memo = $memoDAO->get();
// retrieve entries from db and relate them to entry lists
$entryDAO = new EntryDAO($db);
$entries = $entryDAO->getAll();
$tagDAO = new TagDAO($db);
$content['all_tags'] = $tagDAO->getAll();
// build the view
require 'view.php';
?>


Exemple #5
0
<?php

session_start();
if (!$_SESSION['logged']) {
    echo "<script type='text/javascript'>window.location.replace('login.php');</script>";
    exit;
}
require_once '../init.php';
require_once "../lib/dao/entryDAO.php";
require_once "../lib/dao/tagDAO.php";
$name = $_POST['name'];
$url = $_POST['url'];
$details = $_POST['details'];
$tags_string = $_POST['tags'];
$entryDAO = new EntryDAO($db);
$entry = new Entry(0, $name, $url, $details);
//Create and attach tags
$tags_array = preg_split("/[\\s,]+/", $tags_string);
$tags = Tag::fromStringArray($tags_array);
$entry->setTags($tags);
// Entry will be created id db and its ID will be updated
$entryDAO->save($entry);
//Return the id of the created entry
echo json_encode($entry->getId());
Exemple #6
0
require_once "lib/Zend/Search/Lucene.php";
require_once "dao/entryDAO.php";
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
$indexPath = $CONFIG['indexPath'];
$index = Zend_Search_Lucene::create($indexPath);
class EntryDocument extends Zend_Search_Lucene_Document
{
    /**
     * Constructor. Creates our indexable document and adds all
     * necessary fields to it using the passed in document
     */
    public function __construct($document)
    {
        $this->addField(Zend_Search_Lucene_Field::UnIndexed('id_entry', $document->getId()));
        $this->addField(Zend_Search_Lucene_Field::Keyword('url', $document->getUrl()));
        $this->addField(Zend_Search_Lucene_Field::UnIndexed('creation_date', $document->getCreationDate()));
        $this->addField(Zend_Search_Lucene_Field::Text('name', $document->getName()), 'utf-8');
        $this->addField(Zend_Search_Lucene_Field::Text('content', $document->getDetails()));
        $this->addField(Zend_Search_Lucene_Field::Text('tag', $document->getImplodedTags()));
    }
}
$entryDAO = new EntryDAO($db);
$documents = $entryDAO->getAll();
// create our index
$index = Zend_Search_Lucene::create($indexPath);
foreach ($documents as $document) {
    $index->addDocument(new EntryDocument($document));
}
// write the index to disk
$index->commit();
echo "Indexing done";
Exemple #7
0
session_start();
if (!$_SESSION['logged']) {
    echo "<script type='text/javascript'>window.location.replace('login.php');</script>";
    exit;
}
require_once '../init.php';
require_once '../lib/search/searchEngine.php';
require_once '../lib/Zend/Search/Lucene.php';
require_once '../lib/dao/entryDAO.php';
$query = $_REQUEST['query'];
$searchEngine = new SearchEngine($db);
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
Zend_Search_Lucene_Search_Query_Wildcard::setMinPrefixLength(0);
$index = Zend_Search_Lucene::open($CONFIG['indexPath']);
$entryDAO = new EntryDAO($db);
if (isset($_GET['query']) && $_GET['query'] != "") {
    $query = trim($query);
    $query .= "*";
    try {
        $hits = $index->find($query);
    } catch (Zend_Search_Lucene_Exception $ex) {
        $hits = array();
    }
    $entries = array();
    if ($hits) {
        foreach ($hits as $hit) {
            //try{
            $entries[] = $entryDAO->get($hit->id_entry);
            //}
            //catch ()