Ejemplo n.º 1
0
/**
* Sends the note data in json format
*/
function send_note_foredit()
{
    $id = rmc_server_var($_GET, 'id', 0);
    if ($id <= 0) {
        echo json_encode(array('message' => __('Note id not provided!', 'docs'), 'error' => 1));
        die;
    }
    $ref = new RDReference($id);
    if ($ref->isNew()) {
        echo json_encode(array('message' => __('Specified note does not exists!', 'docs'), 'error' => 1));
        die;
    }
    $ret = array('id' => $ref->id(), 'title' => $ref->getVar('title'), 'res' => $ref->getVar('id_res'), 'text' => $ref->getVar('text', 'e'), 'error' => 0);
    echo json_encode($ret);
    die;
}
Ejemplo n.º 2
0
/**
* Build a note or reference
* 
* @param int ID of note
*/
function rd_build_note($id)
{
    global $xoopsModuleConfig;
    static $note_number = 1;
    $ref = new RDReference($id);
    if ($ref->isNew()) {
        return;
    }
    $tpl = RMTemplate::get();
    $rep = array('<p>', '</p>');
    $tpl->append('references', array('id' => $ref->id(), 'text' => str_replace($rep, '', $ref->getVar('text'))));
    $ret = "<a name='top{$note_number}'></a><sup><a class='note-link' href='#note-{$note_number}' title='" . $ref->getVar('title') . "'>";
    $ret .= "{$note_number}</a></sup>";
    $note_number++;
    return $ret;
}
Ejemplo n.º 3
0
 /**
  * Get all references list according to given parameters
  * @param int Resource ID
  * @param Referenced var to return results count
  * @param string Search keyword
  * @param int Start results
  * @param int Results number limit
  * @return array
  */
 public function references($res = 0, &$count, $search = '', $start = 0, $limit = 15)
 {
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_references') . ($res > 0 ? " WHERE id_res='{$res}'" : '');
     if ($search != '') {
         $sql .= ($res > 0 ? " AND " : " WHERE ") . " (title LIKE '%{$k}%' OR text LIKE '%{$k}%')";
     }
     if ($res > 0) {
         $res = new RDResource($res);
     }
     list($num) = $db->fetchRow($db->query($sql));
     $limit = $limit <= 0 ? 15 : $limit;
     $count = $num;
     //Fin de navegador de páginas
     $sql = str_replace("COUNT(*)", "*", $sql);
     $sql .= " ORDER BY id_ref DESC LIMIT {$start},{$limit}";
     $result = $db->query($sql);
     $references = array();
     while ($rows = $db->fetchArray($result)) {
         $ref = new RDReference();
         $ref->assignVars($rows);
         if ($res->isNew()) {
             $res = new RDResource($ref->resource());
         }
         $references[] = array('id' => $ref->id(), 'title' => $ref->getVar('title'), 'text' => substr(TextCleaner::getInstance()->clean_disabled_tags($ref->getVar('text')), 0, 50) . "...", 'resource' => $res->getVar('title'));
     }
     return $references;
 }
Ejemplo n.º 4
0
/**
* desc Edita Referencias
**/
function rd_edit_note()
{
    global $xoopsModule;
    RMTemplate::get()->assign('xoops_pagetitle', __('Editing Note', 'docs'));
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Editing Note', 'docs'));
    xoops_cp_header();
    $id = rmc_server_var($_GET, 'id', 0);
    $id_res = rmc_server_var($_GET, 'res', 0);
    if ($id_res <= 0) {
        redirectMsg('./notes.php', __('Document not specified', 'docs'), 1);
        die;
    }
    $res = new RDResource($id_res);
    if ($res->isNew()) {
        redirectMsg('./notes.php', __('Specified Document does not exists!', 'docs'), 1);
        die;
    }
    if ($id <= 0) {
        redirectMsg('./notes.php?res=' . $res, __('Note not specified', 'docs'), 1);
        die;
    }
    //Verifica que referencia exista
    $ref = new RDReference($id);
    if ($ref->isNew()) {
        redirectMsg('./notes.php?res=' . $res, __('Specified note does not exists!', 'docs'), 1);
        die;
    }
    //Formulario
    $form = new RMForm(__('Edit Note', 'docs'), 'frmref', 'notes.php');
    $form->addElement(new RMFormText(__('Title', 'docs'), 'title', 50, 150, $ref->getVar('title')), true);
    $form->addElement(new RMFormTextArea(__('Content', 'docs'), 'reference', 5, 50, $ref->getVar('text', 'e')), true);
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', __('Save Changes', 'docs'), 'submit');
    $buttons->addButton('cancel', __('Cancel', 'docs'), 'button', 'onclick="window.location=\'notes.php?res=' . $res . '\';"');
    $form->addElement($buttons);
    $form->addElement(new RMFormHidden('action', 'saveedit'));
    $form->addElement(new RMFormHidden('id', $id));
    $form->addElement(new RMFormHidden('res', $id_res));
    $form->display();
    xoops_cp_footer();
}