Exemplo n.º 1
0
 private function replaceReferenceWithLink($ref)
 {
     $delim = strpos($ref, "|");
     $title = $delim !== false ? substr($ref, 0, $delim) : $ref;
     $text = $delim !== false ? substr($ref, $delim + 1) : $title;
     $cm = new \Manager\CardsManager();
     $card = $cm->findByTitle($title);
     if ($card == null) {
         return '<a class="createlink" href="' . generate_url("cards", "add", array("title" => $title)) . "\">{$text}</a>";
     } else {
         return '<a href="' . generate_url("cards", "show", array("cardId" => $card->getId())) . "\">{$text}</a>";
     }
 }
Exemplo n.º 2
0
 public function loadCreate($title, $frontHtml, $backHtml, $ajax, $tags)
 {
     $cm = new \Manager\CardsManager();
     $c = $cm->createCard(null, $title, $frontHtml, $backHtml, explode(",", $tags));
     if ($ajax) {
         echo json_encode($c);
         $this->dontRender();
     } else {
         if ($c instanceof \Model\Card) {
             $this->addInfo("Card '" . $c->getTitle() . "' successfully created");
             $this->redirect();
         } else {
             $this->addError("Error: {$c}");
             $this->redirect(null, "add");
         }
     }
 }
Exemplo n.º 3
0
<?php

set_time_limit(0);
$um = new Manager\UserManager();
$um->register("Max Mustermann", "*****@*****.**", "test", "test");
$um->login("test", "test");
$cm = new \Manager\CardsManager();
import_dir(__DIR__ . '/exampleCards', array());
function import_dir($path, $tags)
{
    global $cm;
    $dir = opendir($path);
    while (false !== ($entry = readdir($dir))) {
        $f = $path . "/" . $entry;
        if (strlen($entry) > 2) {
            if (is_dir($f)) {
                import_dir($f, array_merge($tags, array($entry)));
            } else {
                if (is_file($f)) {
                    $cm->importFile($f, array_merge($tags, array($entry)));
                }
            }
        }
    }
}
$mnm = new Manager\MindMapNodeManager();
$map = $mnm->createMindMap("niceMindMap");
$cards = $cm->getCardsByUser($um->getLoggedInUser());
$x = 0;
foreach ($cards as $c) {
    if ($x++ == 5) {