Jakweb.ch stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
clouddesk/template/business/functions_cms.php

223 lines
12 KiB

1 year ago
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 1.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2021 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
// Menu builder function, parentId 0 is the root
function jak_build_menu($parent, $menu, $active, $mainclass, $dropdown, $dropclass, $subclass, $admin, $client, $firstli = "", $firsta = "", $from = 0, $to = 0) {
$html = '';
if (isset($menu['parents'][$parent])) {
if (isset($from) && is_numeric($from) && isset($to) && is_numeric($to) && $to != 0) {
$mpr = array_slice($menu['parents'][$parent], $from, $to);
} else {
$mpr = $menu['parents'][$parent];
}
$html .= '<ul class="'.$mainclass.'">';
foreach ($mpr as $itemId) {
if (!isset($menu['parents'][$itemId]) && (($menu["items"][$itemId]["access"] == 1 && (!$admin && !$client)) || $menu["items"][$itemId]["access"] == 2) || ($menu["items"][$itemId]["access"] == 3 && ($admin || $client))) {
$html .= '<li'.($firstli ? ' class="'.$firstli.($active == $menu["items"][$itemId]["url_slug"] ? ' active"' : '"') : ($active == $menu["items"][$itemId]["url_slug"] ? ' class="active"' : '')).'><a'.($firsta ? ' class="'.$firsta.'"' : '').' href="'.($menu["items"][$itemId]["url_slug"] ? JAK_rewrite::jakParseurl($menu["items"][$itemId]["url_slug"]) : BASE_URL).'">'.$menu["items"][$itemId]["title"].'</a></li>';
}
if (isset($menu['parents'][$itemId])) {
$html .= '<li'.($firstli ? ' class="'.$firstli.($active == $menu["items"][$itemId]["url_slug"] ? ($dropdown ? ' active '.$dropdown.'"' : '"') : ($dropdown ? $dropdown.'"' : '"')) : ($active == $menu["items"][$itemId]["url_slug"] ? ($dropdown ? ' class="active '.$dropdown.'"' : '') : ($dropdown ? ' class="'.$dropdown.'"' : ''))).'><a'.($firsta ? ' class="'.$firsta.'"' : BASE_URL).' href="'.JAK_rewrite::jakParseurl($menu["items"][$itemId]["url_slug"]).'">'.$menu["items"][$itemId]["title"].'</a>';
$html .= jak_build_menu($itemId, $menu, $active, $dropclass, $subclass, $dropclass, $subclass, $admin);
$html .= '</li>';
}
}
if ($admin) {
$html .= '<li'.($firstli ? ' class="'.$firstli.'"' : '').'><a'.($firsta ? ' class="'.$firsta.'"' : '').' href="'.BASE_URL.JAK_OPERATOR_LOC.'/">Operator</a></li>';
}
$html .= '</ul>';
}
return $html;
}
function produce_replacement($match) {
$producerName = 'evaluate_'.strtolower($match[1]);
return function_exists($producerName) ? $producerName() : null;
}
function evaluate_searchblock() {
global $jkl;
global $cms_text;
global $BT_LANGUAGE;
global $jakclient;
global $jakclient;
ob_start(); // Start output buffer capture.
include(APP_PATH.'template/'.JAK_FRONT_TEMPLATE.'/tplblocks/searchblock.php'); // Include your template.
$output = ob_get_contents(); // This contains the output of yourtemplate.php
// Manipulate $output...
ob_end_clean(); // Clear the buffer.
return $output; // Print everything.
}
function evaluate_blognew() {
global $jkl;
global $jakdb;
global $cms_text;
global $BT_LANGUAGE;
global $pageid;
global $jakclient;
ob_start(); // Start output buffer capture.
include(APP_PATH.'template/'.JAK_FRONT_TEMPLATE.'/tplblocks/blognew.php'); // Include your template.
$output = ob_get_contents(); // This contains the output of yourtemplate.php
// Manipulate $output...
ob_end_clean(); // Clear the buffer.
return $output; // Print everything.
}
function evaluate_faqnew() {
global $jkl;
global $cms_text;
global $jakdb;
global $BT_LANGUAGE;
global $jakclient;
global $pageid;
ob_start(); // Start output buffer capture.
include(APP_PATH.'template/'.JAK_FRONT_TEMPLATE.'/tplblocks/faqnew.php'); // Include your template.
$output = ob_get_contents(); // This contains the output of yourtemplate.php
// Manipulate $output...
ob_end_clean(); // Clear the buffer.
return $output; // Print everything.
}
function evaluate_supportnew() {
global $jkl;
global $cms_text;
global $jakdb;
global $jakclient;
global $jakuser;
global $pageid;
global $jakclient;
ob_start(); // Start output buffer capture.
include(APP_PATH.'template/'.JAK_FRONT_TEMPLATE.'/tplblocks/supportnew.php'); // Include your template.
$output = ob_get_contents(); // This contains the output of yourtemplate.php
// Manipulate $output...
ob_end_clean(); // Clear the buffer.
return $output; // Print everything.
}
function evaluate_contact() {
global $jkl;
global $cms_text;
global $BT_LANGUAGE;
global $pageid;
global $jakclient;
ob_start(); // Start output buffer capture.
include(APP_PATH.'template/'.JAK_FRONT_TEMPLATE.'/tplblocks/contactform.php'); // Include your template.
$output = ob_get_contents(); // This contains the output of yourtemplate.php
// Manipulate $output...
ob_end_clean(); // Clear the buffer.
return $output; // Print everything.
}
// Get comments votes
function jak_comment_votes($votes) {
if (isset($votes) && $votes != 0) {
if ($votes < 0) {
return 'danger';
} else {
return 'success';
}
} else {
return 'default';
}
}
function jak_build_comments($parent, $comm, $access, $session, $approve, $reply, $report, $status) {
$html = '';
if (isset($comm['subcomm'][$parent])) {
foreach ($comm['subcomm'][$parent] as $comID) {
if (!isset($comm['subcomm'][$comID])) {
$html .= '<div class="media">
<a class="float-left" href="javascript:void(0)">
<div class="avatar">
<img class="media-object" src="'.$comm["comm"][$comID]["avatar"].'" alt="'.$comm["comm"][$comID]["username"].'">
</div>
</a>
<div class="media-body">
<h5 class="media-heading">'.$comm["comm"][$comID]["username"].'</h5>
<div class="com" id="msgid_'.$comm["comm"][$comID]["id"].'"><p class="m-0 p-0">'.$comm["comm"][$comID]["message"].'</p>'.(($comm["comm"][$comID]["approve"] == 0 && ((!empty($comm["comm"][$comID]["session"]) && $session == $comm["comm"][$comID]["session"]) || $access)) ? '<div class="alert alert-info">'.$approve.'</div>' : '').(!$comm["comm"][$comID]["commentid"] ? '<span id="insertPost_'.$comm["comm"][$comID]["id"].'"></span>' : '').'
</div>
<div class="float-right">
'.(JAK_USERISLOGGED && $status && !$comm["comm"][$comID]["commentid"] && $comm["comm"][$comID]["approve"] ? '<a href="javascript:void(0);" data-id="'.$comm["comm"][$comID]["id"].'" class="btn btn-primary btn-link pull-right jak-creply"><i class="fas fa-reply"></i> '.$reply.'</a>' : '').'
<span class="badge badge-pill badge-success"><i class="fa fa-clock" aria-hidden="true"></i> '.$comm["comm"][$comID]["created"].'</span>
<a href="javascript:void(0)" data-cvote="up" data-id="'.$comm["comm"][$comID]["id"].'" class="btn btn-success btn-link pull-right jak-cvote"><i class="far fa-thumbs-up"></i></a>
<span id="jak-cvotec'.$comm["comm"][$comID]["id"].'" class="badge badge-pill badge-'.jak_comment_votes($comm["comm"][$comID]["votes"]).' pull-right mt-3">'.$comm["comm"][$comID]["votes"].'</span>
<a href="javascript:void(0)" data-cvote="down" data-id="'.$comm["comm"][$comID]["id"].'" class="btn btn-danger btn-link pull-right jak-cvote"><i class="far fa-thumbs-down"></i></a>
<!-- Votes -->
'.($access ? '<a href="javascript:void(0);" data-id="'.$comm["comm"][$comID]["id"].'" data-msg="'.$comm["comm"][$comID]["message"].'" class="btn btn-primary btn-link pull-right jak-epost"><i class="fa fa-pencil"></i></a> <a href="'.$comm["comm"][$comID]["parseurl1"].'" class="btn btn-primary btn-link pull-right"><i class="fa fa-trash"></i></a>' : "").($report && $comm["comm"][$comID]["report"] == 0 ? ' <a href="'.$comm["comm"][$comID]["parseurl2"].'" class="btn btn-primary btn-link pull-right"><i class="fa fa-exclamation-triangle"></i></a>' : "").'
</div>
</div>
</div>';
}
if (isset($comm['subcomm'][$comID])) {
$html .= '<div class="media">
<a class="float-left" href="javascript:void(0)">
<div class="avatar">
<img class="media-object" alt="'.$comm["comm"][$comID]["username"].'" src="'.$comm["comm"][$comID]["avatar"].'">
</div>
</a>
<div class="media-body">
<h5 class="media-heading">'.$comm["comm"][$comID]["username"].'</h5>
<p class="m-0 p-0">'.$comm["comm"][$comID]["message"].'</p>
<div class="float-right">
'.(JAK_USERISLOGGED && $status && !$comm["comm"][$comID]["commentid"] ? '<a href="javascript:void(0);" data-id="'.$comm["comm"][$comID]["id"].'" class="btn btn-primary btn-link pull-right jak-creply"><i class="fas fa-reply"></i> '.$reply.'</a>' : '').'
<span class="badge badge-pill badge-success"><i class="fa fa-clock" aria-hidden="true"></i>'.$comm["comm"][$comID]["created"].'</span>
<a href="javascript:void(0)" data-cvote="up" data-id="'.$comm["comm"][$comID]["id"].'" class="btn btn-success btn-link pull-right jak-cvote"><i class="far fa-thumbs-up"></i></a>
<span id="jak-cvotec'.$comm["comm"][$comID]["id"].'" class="badge badge-pill badge-'.jak_comment_votes($comm["comm"][$comID]["votes"]).' pull-right mt-3">'.$comm["comm"][$comID]["votes"].'</span>
<a href="javascript:void(0)" data-cvote="down" data-id="'.$comm["comm"][$comID]["id"].'" class="btn btn-danger btn-link pull-right jak-cvote"><i class="far fa-thumbs-down"></i></a>
'.($access ? '<a href="javascript:void(0);" data-id="'.$comm["comm"][$comID]["id"].'" data-msg="'.$comm["comm"][$comID]["message"].'" class="btn btn-primary btn-link pull-right jak-epost"><i class="fa fa-pencil"></i></a> <a href="'.$comm["comm"][$comID]["parseurl1"].'" class="btn btn-primary btn-link pull-right"><i class="fa fa-trash"></i></a>' : "").($report && $comm["comm"][$comID]["report"] == 0 ? ' <a href="'.$comm["comm"][$comID]["parseurl2"].'" class="btn btn-primary btn-link pull-right"><i class="fa fa-exclamation-triangle"></i></a>' : "").'</div><div class="clearfix"></div>';
$html .= jak_build_comments($comID, $comm, $access, $session, $approve, $reply, $report, $status);
$html .= '</div></div>';
if (!$comm["comm"][$comID]["commentid"]) {
$html .= '<span id="insertPost_'.$comm["comm"][$comID]["id"].'"></span>';
}
}
}
}
return $html;
}
function jak_next_page($blogid, $opid, $perm, $lang) {
global $jakdb;
if ($perm) {
$result = $jakdb->get("blog", ["id", "title"], ["AND" => ["id[>]" => $blogid, "opid" => $opid, "lang" => $lang, "active" => 1], "ORDER" => ["id" => "ASC"]]);
} else {
$result = $jakdb->get("blog", ["id", "title"], ["AND" => ["membersonly" => 0, "id[>]" => $blogid, "opid" => $opid, "lang" => $lang, "active" => 1], "ORDER" => ["id" => "ASC"]]);
}
if ($result) {
return $result;
} else
return false;
}
function jak_previous_page($blogid, $opid, $perm, $lang) {
global $jakdb;
if ($perm) {
$result = $jakdb->get("blog", ["id", "title"], ["AND" => ["id[<]" => $blogid, "opid" => $opid, "lang" => $lang, "active" => 1], "ORDER" => ["id" => "DESC"]]);
} else {
$result = $jakdb->get("blog", ["id", "title"], ["AND" => ["membersonly" => 0, "id[<]" => $blogid, "opid" => $opid, "lang" => $lang, "active" => 1], "ORDER" => ["id" => "DESC"]]);
}
if ($result) {
return $result;
} else
return false;
}
?>