/** * Build a figure * * @param int ID of figure * @return string */ function rd_build_figure($id) { if ($id <= 0) { return; } $fig = new RDFigure($id); if ($fig->isNew()) { return; } ob_start(); include RMEvents::get()->run_event('docs.template.build.figure', RMTemplate::get()->get_template('specials/rd_figure.php', 'module', 'docs')); $ret = ob_get_clean(); return $ret; }
/** * Get all figures 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 figures($res = 0, &$count, $search = '', $start = 0, $limit = 15) { $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_figures') . ($res > 0 ? " WHERE id_res='{$res}'" : ''); if ($search != '') { $sql .= ($res > 0 ? " AND " : " WHERE ") . " (desc LIKE '%{$k}%' OR content 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_fig DESC LIMIT {$start},{$limit}"; $result = $db->query($sql); $figures = array(); while ($rows = $db->fetchArray($result)) { $ref = new RDFigure(); $ref->assignVars($rows); if ($res->isNew()) { $res = new RDResource($ref->resource()); } $figures[] = array('id' => $ref->id(), 'title' => $ref->getVar('title'), 'desc' => $ref->getVar('desc'), 'content' => substr(TextCleaner::getInstance()->clean_disabled_tags($ref->getVar('content')), 0, 50) . "...", 'resource' => $res->getVar('title')); } return $figures; }
/** * @desc Almacena toda la información referente a la figura **/ function saveFigures($edit = 0) { global $xoopsSecurity; foreach ($_POST as $k => $v) { ${$k} = $v; } $ruta = 'id=' . $id . '&pag=' . $pag . '&search=' . $search; if (!$xoopsSecurity->check()) { redirectMsg('./figures.php?' . $ruta, __('Session token expired!', 'docs'), 1); die; } //Comprobar publicacion valida if ($id <= 0) { redirectMsg('./figures.php?' . $ruta, __('No Document has been selected!', 'docs'), 1); die; } //Comprobar publicación existente existente $res = new RDResource($id); if ($res->isNew()) { redirectMsg('./figures.php?' . $ruta, __('Specified Document does not exists!'), 1); die; } if ($edit) { //Comprueba que la figura sea válida if ($id_fig <= 0) { redirectMsg('./figures.php?' . $ruta, __('No figure has been selected!', 'docs'), 1); die; } //Comprueba si existe la figura $fig = new RDFigure($id_fig); if ($fig->isNew()) { redirectMsg('./figures.php?' . $ruta, __('Specified figure does not exists!', 'docs'), 1); die; } } else { $fig = new RDFigure(); } $fig->setVar('id_res', $id); $fig->setVar('attrs', $attrs); $fig->setVar('desc', $desc); $fig->setVar('content', $content); $fig->setVar('title', $title); if (!$fig->save()) { redirectMsg('./figures.php?action=new&' . $ruta, __('Database could not be updated!', 'docs'), 1); } else { redirectMsg('./figures.php?' . $ruta, __('Database updated successfully!', 'docs'), 0); } }
/** * @desc Almacena información perteneciente a la figura **/ function rd_save_figures($edit = 0) { global $xoopsSecurity; foreach ($_POST as $k => $v) { ${$k} = $v; } $ruta = "?res={$res}"; if (!$xoopsSecurity->validateToken()) { redirectMsg('./figures.php' . $ruta, __('Session token expired!', 'docs'), 1); die; } if ($edit) { //Verifica que referencia sea válida if ($id <= 0) { redirectMsg('./figures.php' . $ruta, __('Figure id not specified!', 'docs'), 1); die; } //Verifica que referencia exista $fig = new RDFigure($id); if ($fig->isNew()) { redirectMsg('./figures.php' . $ruta, __('Specified figure does not exists!', 'docs'), 1); die; } } else { $fig = new RDFigure(); } $fig->setVar('title', $title); $fig->setVar('desc', $desc); $fig->setVar('content', $figure); $fig->setVar('id_res', $res); $fig->setVar('attrs', $attrs); if ($fig->save()) { redirectMsg('./figures.php?action=locate&res=' . $res . '&id=' . $fig->id(), __('Figure saved successfully!', 'docs'), 0); die; } else { redirectMsg('./figures.php?action=locate&id=' . $fig->id() . '&res=' . $res, __('Figure could not be saved!', 'docs') . '<br />' . $fig->errors(), 1); die; } }