15 public function get(){
18 if (!isset($instance))
31 if (!isset($rmc_configs)){
32 $db = XoopsDatabaseFactory::getDatabaseConnection();
33 $sql =
"SELECT mid FROM ".$db->prefix(
"modules").
" WHERE dirname='rmcommon'";
36 include_once XOOPS_ROOT_PATH.
'/kernel/object.php';
37 include_once XOOPS_ROOT_PATH.
'/kernel/configitem.php';
38 include_once XOOPS_ROOT_PATH.
'/class/criteria.php';
39 include_once XOOPS_ROOT_PATH.
'/class/module.textsanitizer.php';
41 $result =
$db->query(
"SELECT * FROM ".
$db->prefix(
"config").
" WHERE conf_modid='$id'");
44 $config =
new XoopsConfigItem();
45 $config->assignVars($row);
46 $rmc_configs[$config->getVar(
'conf_name')] = $config->getConfValueForOutput();
52 if(isset($rmc_configs[$name]))
return $rmc_configs[$name];
62 $db = XoopsDatabaseFactory::getDatabaseConnection();
64 $sql =
"SELECT COUNT(*) FROM ".$db->prefix($table);
65 $sql .= $filters!=
'' ?
" WHERE $filters" :
'';
80 RMTemplate::get()->add_tool(
__(
'Users List',
'rmcommon'),
'users.php',
'images/users.png',
'allusers');
81 RMTemplate::get()->add_tool(
__(
'Add User',
'rmcommon'),
'users.php?action=new',
'images/user_add.png',
'newuser');
85 RMTemplate::get()->add_tool(
__(
'Categories List',
'rmcommon'),
'images.php?action=showcats',
'images/category.png',
'showcategories');
86 RMTemplate::get()->add_tool(
__(
'Add Category',
'rmcommon'),
'images.php?action=newcat',
'images/category_add.png',
'newcategory');
89 RMTemplate::get()->add_tool(
__(
'Images',
'rmcommon'),
'images.php?category='.
$cat,
'images/image.png',
'showimages');
91 RMTemplate::get()->add_tool(
__(
'Add Images',
'rmcommon'),
'images.php?action=new'.(
$cat>0?
"&category=$cat":
''),
'images/image_add.png',
'addimages');
95 RMTemplate::get()->add_tool(
__(
'Dashboard',
'rmcommon'),
'index.php',
'images/dashboard.png',
'dashboard');
96 RMTemplate::get()->add_tool(
__(
'Modules',
'rmcommon'),
'modules.php',
'images/modules.png',
'modules');
97 RMTemplate::get()->add_tool(
__(
'Blocks',
'rmcommon'),
'blocks.php',
'images/blocks.png',
'blocks');
98 RMTemplate::get()->add_tool(
__(
'Users',
'rmcommon'),
'users.php',
'images/users.png',
'users');
99 RMTemplate::get()->add_tool(
__(
'Images',
'rmcommon'),
'images.php',
'images/images.png',
'imgmanager');
100 RMTemplate::get()->add_tool(
__(
'Comments',
'rmcommon'),
'comments.php',
'images/comments.png',
'comments');
101 RMTemplate::get()->add_tool(
__(
'Plugins',
'rmcommon'),
'plugins.php',
'images/plugin.png',
'plugins');
105 RMTemplate::get()->add_tool(
__(
'Updates',
'rmcommon'),
'updates.php',
'images/updates.png',
'updates');
119 $toImplode = array();
120 foreach ($array as $key => $value) {
121 if (is_array($value)) {
122 $toImplode[] = self::urlencode_array($value,
"{$name}[{$key}]", $separator);
124 $toImplode[] =
"{$name}[{$key}]=".urlencode($value);
127 return implode($separator, $toImplode);
140 if (count($groups)==1 && $groups[0] == 0){
141 $ret[] =
__(
'All',
'rmcommon');
142 return $list ?
__(
'All',
'rmcommon') :
$ret;
145 if(in_array(0, $groups))
$ret[] =
__(
'All',
'rmcommon');
148 $db = XoopsDatabaseFactory::getDatabaseConnection();
149 $sql =
"SELECT name FROM ".$db->prefix(
"groups").
" WHERE groupid IN(".implode(
',',$groups).
")";
152 $ret[] = $row[
'name'];
155 if ($list)
return implode(
', ',
$ret);
165 $db = XoopsDatabaseFactory::getDatabaseConnection();
166 $sql =
"SELECT * FROM ".$db->prefix(
"rmc_img_cats").
" $filters";
168 $categories = array();
171 $tc->assignVars($row);
173 $categories[] = array(
175 'name' => $tc->getVar(
'name')
197 define(
'COMMENTS_INCLUDED', 1);
198 $db = XoopsDatabaseFactory::getDatabaseConnection();
202 $params = urlencode($params);
203 $sql =
"SELECT * FROM ".$db->prefix(
"rmc_comments").
" WHERE status='approved' AND id_obj='$obj' AND params='$params' AND type='$type' AND parent='$parent'".($user==null?
'':
" AND user='$user'").
" ORDER BY posted";
212 $com->assignVars($row);
215 if(!isset($ecache[$com->getVar(
'user')])){
216 $ecache[$com->getVar(
'user')] =
new RMCommentUser($com->getVar(
'user'));
219 $editor = $ecache[$com->getVar(
'user')];
221 if($editor->getVar(
'xuid')>0){
223 if(!isset($ucache[$editor->getVar(
'xuid')])){
224 $ucache[$editor->getVar(
'xuid')] =
new XoopsUser($editor->getVar(
'xuid'));
227 $user = $ucache[$editor->getVar(
'xuid')];
230 'id' => $user->getVar(
'uid'),
231 'name' => $user->getVar(
'uname'),
232 'email' => $user->getVar(
'email'),
233 'posts' => $user->getVar(
'posts'),
234 'avatar'=> XOOPS_UPLOAD_URL.
'/'.$user->getVar(
'user_avatar'),
235 'rank' => $user->rank(),
236 'url' => $user->getVar(
'url')!=
'http://'?$user->getVar(
'url'):
''
243 'name' => $editor->getVar(
'name'),
244 'email' => $editor->getVar(
'email'),
248 'url' => $editor->getVar(
'url')!=
'http://'?$editor->getVar(
'url'):
''
253 if ($xoopsUser && $xoopsUser->isAdmin()){
254 $editlink =
RMCURL.
'/comments.php?action=edit&id='.$com->id().
'&ret='.urlencode(self::current_url());
256 $time_limit = time() - $com->getVar(
'posted');
257 if($xoopsUser && $xoopsUser->getVar(
'uid')==$editor->getVar(
'xuid') && $time_limit<(
$rmc_config[
'edit_limit']*3600)){
258 $editlink =
RMCURL.
'/post_comment.php?action=edit&id='.$com->id().
'&ret='.urlencode(self::current_url());
265 'id' => $row[
'id_com'],
268 'posted' => sprintf(
__(
'Posted on %s'), formatTimestamp($com->getVar(
'posted'),
'l')),
269 'ip' => $com->getVar(
'ip'),
276 $comms =
RMEvents::get()->run_event(
'rmcommon.loading.comments', $comms, $obj, $params,
$type, $parent, $user);
278 $xoopsTpl->assign(
'lang_edit',
__(
'Edit',
'rmcommon'));
281 $xoopsTpl->assign(
'comments', $comms);
299 global $xoopsTpl, $xoopsRequestUri,
$xoopsUser;
301 $config = self::configs();
303 if (!$config[
'enable_comments']){
307 if (!$xoopsUser && !$config[
'anonymous_comments']){
311 if (!defined(
'COMMENTS_INCLUDED')){
312 define(
'COMMENTS_INCLUDED', 1);
315 $xoopsTpl->assign(
'enable_comments_form', 1);
318 'show_name' => !($xoopsUser),
319 'lang_name' =>
__(
'Name',
'rmcommon'),
320 'show_email' => !($xoopsUser),
321 'lang_email' =>
__(
'Email address',
'rmcommon'),
322 'show_url' => !($xoopsUser),
323 'lang_url' =>
__(
'Web site',
'rmcommon'),
324 'lang_text' =>
__(
'Your comment',
'rmcommon'),
325 'lang_submit' =>
__(
'Submit Comment',
'rmcommon'),
326 'lang_title' =>
__(
'Submit a comment',
'rmcommon'),
328 'actionurl' =>
RMCURL.
'/post_comment.php',
329 'params' => urlencode($params),
330 'update' => urlencode(str_replace(XOOPS_ROOT_PATH,
'',
$file)),
339 $form =
RMEvents::get()->run_event(
'rmcommon.comments.form', $form, $obj, $params,
$type);
343 $(document).ready(function(){
344 $("#rmc-comment-form").validate({
346 comment_name: "'.
__(
'Please specify your name',
'rmcommon').
'",
347 comment_email: "'.
__(
'Please specify a valid email',
'rmcommon').
'",
348 comment_text: "'.
__(
'Please write a message',
'rmcommon').
'",
349 comment_url: "'.
__(
'Please enter a valid URL',
'rmcommon').
'"
354 $xoopsTpl->assign(
'cf', $form);
365 if ($module==
'' || $params ==
'')
return;
367 $db = XoopsDatabaseFactory::getDatabaseConnection();
368 $sql =
"DELETE FROM ".$db->prefix(
"rmc_comments").
" WHERE id_obj='$module' AND params='$params'";
371 RMEvents::get()->run_event(
'rmcommon.deleting.comments', $module, $params);
379 if (isset($_SERVER[
"HTTPS"]) && strtolower($_SERVER[
"HTTPS"]) ==
"on") {$pageURL .=
"s";}
381 $pageURL .= $_SERVER[
"HTTP_HOST"].$_SERVER[
"REQUEST_URI"];
392 if (
$dir==
'')
return;
396 $db = XoopsDatabaseFactory::getDatabaseConnection();
397 $sql =
"SELECT * FROM ".$db->prefix(
"rmc_settings").
" WHERE element='$dir'";
402 $configs[$row[
'name']] = $row;
414 $ret[$name] = $conf[
'value'];
422 foreach ($confs as $name =>
$data){
424 switch (
$data[
'valuetype']) {
426 $confs[$name][
'value'] = intval(
$data[
'value']);
429 $confs[$name][
'value'] = unserialize(
$data[
'value']);
432 $confs[$name][
'value'] = floatval(
$data[
'value']);
435 $confs[$name][
'value'] = stripSlashes(
$data[
'value']);
460 $name = strtolower($name);
461 if (!file_exists(
RMCPATH.
'/plugins/'.$name.
'/'.$name.
'-plugin.php'))
464 include_once
RMCPATH.
'/plugins/'.$name.
'/'.$name.
'-plugin.php';
465 $class = ucfirst($name).
'CUPlugin';
467 if (!class_exists(
$class))
481 $mh = xoops_gethandler(
'module');
482 if (is_numeric(
$mod)){
496 $db = XoopsDatabaseFactory::getDatabaseConnection();
498 $sql =
"SELECT mid, name, dirname FROM " .
$db->prefix(
"modules");
499 if($active>-1 && $active<2)
500 $sql .=
" WHERE isactive=$active";
502 $sql .=
" ORDER BY name";
514 $db = XoopsDatabaseFactory::getDatabaseConnection();
515 $result =
$db->query(
"SELECT dir FROM ".
$db->prefix(
"rmc_plugins").
' WHERE status=1');
534 if(
$id<=0)
return false;
538 if($img->isNew())
return false;
542 $sizes =
$cat->getVar(
'sizes');
544 foreach($sizes as
$s){
545 if($s[
'name'] == $size)
549 $date = explode(
'-', date(
'd-m-Y', $img->getVar(
'date')));
550 $file = XOOPS_UPLOAD_URL.
'/'.$date[2].
'/'.$date[1].
'/';
552 $file .= $img->getVar(
'file');
556 $file .=
'sizes/'.substr($img->getVar(
'file'), 0, -4).
'_'.$s[
'width'].
'x'.$s[
'height'].substr($img->getVar(
'file'), -4);
558 if(!is_file(str_replace(XOOPS_URL, XOOPS_ROOT_PATH,
$file)))
559 return $img->getOriginal();
573 if($description==
'')
return;
577 $description = strip_tags($description);
578 $tpl->add_meta(
'description', $tc->truncate($description, 255));
580 $tpl->add_meta(
'keywords', $keywords);
584 $description = preg_replace(
"/[^[[:alnum:]]]|[\.,:]/",
'', $description);
585 $description = preg_replace(
"/[[:space:]][[:alnum:]]{0,4}[[:space:]]/",
' ',$description);
587 $words = explode(
" ", $description);
589 $keys = array_rand($words,
$limit>count($words) ? count($words) :
$limit);
591 foreach($keys as
$id){
592 $keywords .= $keywords==
'' ? $words[
$id] :
', '.$words[
$id];
595 $tpl->add_meta(
'keywords', $keywords);