function BuildDiv($sitename) { $tpl = new templates(); $page = CurrentPageName(); $md5 = md5($sitename); $boot = new boostrap_form(); $sitename = urlencode($sitename); $categories = buildCategoriesCache(); $ARTICA = $categories["CATEGORIES_ARTICA"]; $CATEGORIES_PERSO = $categories["CATEGORIES_PERSO"]; $categorize = $tpl->_ENGINE_parse_body("{categorize}"); $generic_categories = $tpl->_ENGINE_parse_body("{categories}"); $your_categories = $tpl->_ENGINE_parse_body("{your_categories}"); $find = $tpl->_ENGINE_parse_body("{search}"); if (!is_array($CATEGORIES_PERSO)) { $CATEGORIES_PERSO = array(); } $t = time(); $ART[] = "\n\t<center id='animate-{$md5}'></center>\n\t<div style='text-align:right;margin-bottom:10px' >\n\t<input id='s-{$md5}' class='input-medium search-query' onkeypress='javascript:SearchQuery{$md5}()' type='text'>\n \t<button type='button' id='{$md5}-{$t}' class='btn' OnClick=\"javascript:SearchQuery{$md5}()\">{$find}</button>\n\t</div>\n\t\t\t\n\t<table class='table table-bordered table-hover'>\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t<th colspan=2>" . $tpl->_ENGINE_parse_body("{category}") . "</th>\n\t\t\t\t<th>" . $tpl->_ENGINE_parse_body("{description}") . "</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t\t"; while (list($category, $params) = each($ARTICA)) { $categoryID = trim($category); $categoryID = str_replace(" ", "", $categoryID); $categoryID = str_replace("/", "-", $categoryID); $link = $boot->trswitch("Categorize{$md5}('{$category}','{$sitename}','{$md5}')"); $ART[] = "\n\t\t<tr id='{$md5}-tr-{$categoryID}'>\n\t\t<td {$link} width=1% nowrap>{$params["IMG"]}</td>\n\t\t<td {$link} width=1% nowrap>{$category}</td>\n\t\t<td {$link}>{$params["DESC"]}</td>\n\t\t</tr>"; } $ART[] = "</table>"; $PERS[] = "<table class='table table-bordered table-hover'>\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t<th colspan=2>" . $tpl->_ENGINE_parse_body("{category}") . "</th>\n\t\t\t\t<th>" . $tpl->_ENGINE_parse_body("{description}") . "</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t\t"; while (list($category, $params) = each($CATEGORIES_PERSO)) { $categoryID = trim($category); $categoryID = str_replace(" ", "", $categoryID); $categoryID = str_replace("/", "-", $categoryID); $link = $boot->trswitch("Categorize{$md5}('{$category}','{$sitename}','{$md5}')"); $PERS[] = "\n\t\t<tr id='{$md5}-tr-{$categoryID}'>\n\t\t<td {$link} width=1% nowrap>{$params["IMG"]}</td>\n\t\t<td {$link} width=1% nowrap>{$category}</td>\n\t\t<td {$link}>{$params["DESC"]}</td>\n\t\t</tr>"; } $PERS[] = "</table>"; $html = "\n\t\n\t<div id='dialog-{$md5}' title='{$sitename}'>\n\t<div id='logs-{$md5}'></div>\n\t<H3>{$sitename}</H3>\n\t<ul class='nav nav-tabs' id='site-{$md5}'>\n\t\t<li class='active' id='gen-{$md5}'><a href='javascript:blur();' OnClick=\"javascript:Gecat{$md5}()\">{$generic_categories}</a></li>\n\t\t"; if (count($CATEGORIES_PERSO) > 0) { $html = $html . "<li><a href='javascript:blur();' OnClick=\"javascript:Pers{$md5}()\" id='pers-{$md5}'>{$your_categories}</a></li>"; } $html = $html . "</ul>\n\t\t<div class='tab-pane active' id='site-{$md5}-art'>\n\t\t\t" . @implode("\n", $ART) . "\n\t\t</div>\n\t\t<div class='tab-pane' id='site-{$md5}-pers' style='display:none'>\n\t\t\t" . @implode("\n", $PERS) . "\n\t\t</div>\n\t</div>\n\t\t\t\t\t\n\t<script>\n\tvar md{$md5}='';\n\t\tfunction Gecat{$md5}(){\n\t\t\tdocument.getElementById('gen-{$md5}').className='active';\n\t\t\t\n\t\t\tdocument.getElementById('site-{$md5}-art').className='tab-pane active';\n\t\t\tdocument.getElementById('site-{$md5}-art').style.display='block';\n\t\t\t\n\t\t\tif(document.getElementById('pers-{$md5}')){\n\t\t\t\tdocument.getElementById('pers-{$md5}').className='';\n\t\t\t\tdocument.getElementById('site-{$md5}-pers').classList.remove('active');\n\t\t\t\tdocument.getElementById('site-{$md5}-pers').style.display='none';\n\t\t\t}\n\t\t}\n\t\t\n\t\tfunction SearchQuery{$md5}(){\n\t\t\tvar sid='';\n\t\t\tvar xlogs='';\n\t\t\tvar pos=0;\n\t\t\tvar category='';\n\t\t\tvar pattern=document.getElementById('s-{$md5}').value;\n\t\t\t\n\t\t\tif(pattern.length==0){\n\t\t\t\t\$('#dialog-{$md5} [id^=\"{$md5}-tr-\"]').show();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\$('#dialog-{$md5} [id^=\"{$md5}-tr-\"]').hide();\n\t\t\t\$('#dialog-{$md5} [id^=\"{$md5}-tr-\"]').each(function(){\n \t\t\tif(this.id){\n \t\t\t\tsid=this.id;\n \t\t\t\tvar myRegexp = /{$md5}-tr-(.*?)\$/;\n \t\t\t\tvar match = myRegexp.exec(sid);\n \t\t\t\tcategory=' '+match[1];\n \t\t\t\txlogs=xlogs+'Found <b>'+category+'</b>';\n \t\t\t\tpos=category.search(pattern);\n \t\t\t\tif ( pos>0 ) {\n \t\t\t\t\t\$('#'+sid).show();\n \t\t\t\t\txlogs=xlogs+' <span style=color:red>found</span><br>';\n \t\t\t\t}else{\n \t\t\t\t\txlogs=xlogs+' '+pattern+' '+'<b>'+pos+'</b> not found<br>';\n \t\t\t\t}\n \t\t\t\t\n \t\t\t}\n\t\t\t});\n\t\t\t\n\t\t\t//document.getElementById('logs-{$md5}').innerHTML=xlogs;\n\t\t\t\n\t\t}\n\t\t\n\tvar xCategorize{$md5}= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tdocument.getElementById('animate-{$md5}').innerHTML='';\n\t\tif(results.length>2){\n\t\t\talert(results);\n\t\t\treturn;\n\t\t }\n\t\t\$('#dialog-{$md5}').empty();\n\t\t\$('#dialog-{$md5}').dialog('destroy');\n\t\t\$('#'+md{$md5}).remove();\n\t\tRefreshNotCategorizedTitle();\n\t\t \n\t\t}\t\t\n\t\t\n\t\tfunction Categorize{$md5}(cat,site,md){\n\t\t\tmd{$md5}=md;\n\t\t\tif(!confirm(site +' --> '+cat+' ?')){return;}\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('CATEGORIZE',cat);\n\t\t\tXHR.appendData('WWW',site);\n\t\t\tAnimateDiv('animate-{$md5}');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',xCategorize{$md5});\t\n\t\t}\n\t\t\n\t\t\n\n\t\t\n\t\t\t\t\n\t\t\n\t\tfunction Pers{$md5}(){\n\t\t\tdocument.getElementById('gen-{$md5}').className='';\n\t\t\tdocument.getElementById('pers-{$md5}').className='active';\n\t\t\tdocument.getElementById('site-{$md5}-pers').className='tab-pane active';\n\t\t\tdocument.getElementById('site-{$md5}-art').classList.remove('active');\n\t\t\tdocument.getElementById('site-{$md5}-art').style.display='none';\n\t\t\tdocument.getElementById('site-{$md5}-pers').style.display='block';\n\t\t}\t\n\t</script>\t\t\t\t\n"; return array($html, "\$('#dialog-{$md5}').dialog({autoOpen: false,width: '800px',position: 'top',zIndex:8999});\n\$('#dialog-{$md5}').dialog( 'option', 'height', 700 );", "\$( '#dialog-{$md5}' ).dialog( 'open' );"); }
$cachepath = ''; // Tries to create the cache file in shop root } else { $cachepath = constant(FWR_MENU_CACHE_PATH); } /** * Or we simple load the <languages_id>_categories.ser file and use no query. * @param $categories variable is created in includes/functions/fwr_cat_functions.php * by function buildCategoriesCache() $categories array can be seperated for understanding into 3 sub variables * $categories[<category_id>] holds all of the category info and is multi dimensional * $categories['menuid_string'] contains the id of all the parent categories which is needed by suckertree * $categories['menuid_js'] contains javascript for suckertree that prints var menuids= using $categories['menuid_string'] */ // If the cache file exists OR we are resetting the menu we rebuild the cache using our one query. if (!file_exists($cachepath . $languages_id . "_categories.ser") || defined('FWR_MENU_RESET') && FWR_MENU_RESET == 'true') { $categories = buildCategoriesCache($cachepath, FWR_MENU_ORDER_BY, $languages_id); } else { $categories = loadSerializedFile($cachepath, $languages_id, "_categories.ser"); } /** * @param $menuid_string is set from $categories['menuid_string'] * it is used later by the sitemap addon of this script */ $menuid_string = $categories['menuid_string']; // Print the javascript for the suckertree var menuids echo $categories['menuid_js'] . PHP_EOL; unset($categories['menuid_string'], $categories['menuid_js']); // Housekeeping $boxHeading = BOX_HEADING_CATEGORIES; $corner_top_left = 'rounded'; $corner_top_right = 'rounded';