From: <wis...@us...> - 2017-05-23 05:09:41
|
Revision: 13242 http://sourceforge.net/p/xoops/svn/13242 Author: wishcraft Date: 2017-05-23 05:09:37 +0000 (Tue, 23 May 2017) Log Message: ----------- Tag Module 2.41 (Still in Development - Alpha-1! Added Paths: ----------- XoopsModules/tag/trunk/README.md XoopsModules/tag/trunk/modules/ XoopsModules/tag/trunk/modules/tag/ XoopsModules/tag/trunk/modules/tag/admin/ XoopsModules/tag/trunk/modules/tag/admin/admin.tag.php XoopsModules/tag/trunk/modules/tag/admin/header.php XoopsModules/tag/trunk/modules/tag/admin/index.php XoopsModules/tag/trunk/modules/tag/admin/menu.php XoopsModules/tag/trunk/modules/tag/admin/syn.tag.php XoopsModules/tag/trunk/modules/tag/blocks/ XoopsModules/tag/trunk/modules/tag/blocks/block.php XoopsModules/tag/trunk/modules/tag/blocks/index.html XoopsModules/tag/trunk/modules/tag/class/ XoopsModules/tag/trunk/modules/tag/class/index.html XoopsModules/tag/trunk/modules/tag/class/link.php XoopsModules/tag/trunk/modules/tag/class/tag.php XoopsModules/tag/trunk/modules/tag/footer.php XoopsModules/tag/trunk/modules/tag/header.php XoopsModules/tag/trunk/modules/tag/images/ XoopsModules/tag/trunk/modules/tag/images/delimiter.gif XoopsModules/tag/trunk/modules/tag/images/left_both.gif XoopsModules/tag/trunk/modules/tag/images/mlogo.png XoopsModules/tag/trunk/modules/tag/images/modadminbg.gif XoopsModules/tag/trunk/modules/tag/images/right_both.gif XoopsModules/tag/trunk/modules/tag/include/ XoopsModules/tag/trunk/modules/tag/include/action.module.php XoopsModules/tag/trunk/modules/tag/include/formtag.php XoopsModules/tag/trunk/modules/tag/include/functions.ini.php XoopsModules/tag/trunk/modules/tag/include/functions.php XoopsModules/tag/trunk/modules/tag/include/functions.recon.php XoopsModules/tag/trunk/modules/tag/include/plugin.dist.php XoopsModules/tag/trunk/modules/tag/include/plugin.php XoopsModules/tag/trunk/modules/tag/include/search.inc.php XoopsModules/tag/trunk/modules/tag/include/tagbar.php XoopsModules/tag/trunk/modules/tag/include/vars.php XoopsModules/tag/trunk/modules/tag/index.php XoopsModules/tag/trunk/modules/tag/language/ XoopsModules/tag/trunk/modules/tag/language/english/ XoopsModules/tag/trunk/modules/tag/language/english/admin.php XoopsModules/tag/trunk/modules/tag/language/english/blocks.php XoopsModules/tag/trunk/modules/tag/language/english/config.php XoopsModules/tag/trunk/modules/tag/language/english/index.html XoopsModules/tag/trunk/modules/tag/language/english/main.php XoopsModules/tag/trunk/modules/tag/language/english/modinfo.php XoopsModules/tag/trunk/modules/tag/language/french/ XoopsModules/tag/trunk/modules/tag/language/french/admin.php XoopsModules/tag/trunk/modules/tag/language/french/blocks.php XoopsModules/tag/trunk/modules/tag/language/french/config.php XoopsModules/tag/trunk/modules/tag/language/french/index.html XoopsModules/tag/trunk/modules/tag/language/french/main.php XoopsModules/tag/trunk/modules/tag/language/french/modinfo.php XoopsModules/tag/trunk/modules/tag/language/index.html XoopsModules/tag/trunk/modules/tag/language/schinese/ XoopsModules/tag/trunk/modules/tag/language/schinese/admin.php XoopsModules/tag/trunk/modules/tag/language/schinese/blocks.php XoopsModules/tag/trunk/modules/tag/language/schinese/config.php XoopsModules/tag/trunk/modules/tag/language/schinese/index.html XoopsModules/tag/trunk/modules/tag/language/schinese/main.php XoopsModules/tag/trunk/modules/tag/language/schinese/modinfo.php XoopsModules/tag/trunk/modules/tag/language/schinese_utf8/ XoopsModules/tag/trunk/modules/tag/language/schinese_utf8/admin.php XoopsModules/tag/trunk/modules/tag/language/schinese_utf8/blocks.php XoopsModules/tag/trunk/modules/tag/language/schinese_utf8/config.php XoopsModules/tag/trunk/modules/tag/language/schinese_utf8/index.html XoopsModules/tag/trunk/modules/tag/language/schinese_utf8/main.php XoopsModules/tag/trunk/modules/tag/language/schinese_utf8/modinfo.php XoopsModules/tag/trunk/modules/tag/list.cat.php XoopsModules/tag/trunk/modules/tag/list.tag.php XoopsModules/tag/trunk/modules/tag/plugin/ XoopsModules/tag/trunk/modules/tag/plugin/article.php XoopsModules/tag/trunk/modules/tag/plugin/newbb.php XoopsModules/tag/trunk/modules/tag/sample.php XoopsModules/tag/trunk/modules/tag/sql/ XoopsModules/tag/trunk/modules/tag/sql/index.html XoopsModules/tag/trunk/modules/tag/sql/mysql.150.sql XoopsModules/tag/trunk/modules/tag/sql/mysql.230.sql XoopsModules/tag/trunk/modules/tag/sql/mysql.sql XoopsModules/tag/trunk/modules/tag/templates/ XoopsModules/tag/trunk/modules/tag/templates/blocks/ XoopsModules/tag/trunk/modules/tag/templates/blocks/tag_block_cloud.html XoopsModules/tag/trunk/modules/tag/templates/blocks/tag_block_top.html XoopsModules/tag/trunk/modules/tag/templates/index.html XoopsModules/tag/trunk/modules/tag/templates/style.css XoopsModules/tag/trunk/modules/tag/templates/tag_bar.html XoopsModules/tag/trunk/modules/tag/templates/tag_category_list.html XoopsModules/tag/trunk/modules/tag/templates/tag_category_view.html XoopsModules/tag/trunk/modules/tag/templates/tag_index.html XoopsModules/tag/trunk/modules/tag/templates/tag_list.html XoopsModules/tag/trunk/modules/tag/templates/tag_view.html XoopsModules/tag/trunk/modules/tag/view.cat.php XoopsModules/tag/trunk/modules/tag/view.tag.php XoopsModules/tag/trunk/modules/tag/xoops_version.php Removed Paths: ------------- XoopsModules/tag/trunk/tag/ Added: XoopsModules/tag/trunk/README.md =================================================================== --- XoopsModules/tag/trunk/README.md (rev 0) +++ XoopsModules/tag/trunk/README.md 2017-05-23 05:09:37 UTC (rev 13242) @@ -0,0 +1,207 @@ +#Tag Module for XOOPS 2.5 +##Version 2.xx (Still in Development) +### Author: Simon Roberts <simon@snails.email> + +This module provides a centralized toolkit including input, display, stats and substantial more comprehensive applications, so that each module does not need to develop its own tag handling scripts. + +Check http://en.wikipedia.org/wiki/Tags for more info about "tag" + +#Usage of the Tag Module in your XOOPS Module +To enable tag for a module ("mymodule"), following steps are need: +* add tag input box to your item edit form (required) +* add tag storage to your item submission page (required) +* define functions to build info of tagged items (required) +* add tag display API to your item display page and include tag template in your item template (optional) +* add module tag view page and tag list page (optional) +* add module tag blocks (optional) + +##Step 1: add tag input box +This is how you would set up an inclusion of the tag module in an itemised edit form in your module, this is not explicit example and could have variegates for the module you are writing or editing. + + // File: edit.item.php + $itemid = $item_obj->isNew() ? 0 : $item_obj->getVar("itemid"); + include_once XOOPS_ROOT_PATH . "/modules/tag/include/formtag.php"; + $form_item->addElement(new XoopsFormTag("item_tag", 60, 255, $itemid, $catid = 0)); + +##Step 2: add tag storage after item storage +This is how you would set up an inclusion of the tag module in an itemised submition form in your module, this is not explicit example and could have variegates for the module you are writing or editing. + + // File: submit.item.php + $tag_handler = xoops_getmodulehandler('tag', 'tag'); + $tag_handler->updateByItem($_POST["item_tag"], $itemid, $xoopsModule->getVar("dirname"), $catid = 0); + +##Step 3: define functions to build info of tagged items of module +This is the plugin for the tag module to enable the taging in both the tag module and the module you are writing/editing! +Editing File Example: /modules/tag/plugin/mymodule.php + +###Get item fields: title, content, time, link, uid, uname, tags + function mymodule_tag_iteminfo(&$items) + { + $items_id = array(); + foreach (array_keys($items) as $cat_id) { + // Some handling here to build the link upon catid + // If catid is not used, just skip it + foreach (array_keys($items[$cat_id]) as $item_id) { + // In article, the item_id is "art_id" + $items_id[] = intval($item_id); + } + } + $item_handler =& xoops_getmodulehandler("item", "module"); + $items_obj = $item_handler->getObjects(new Criteria("itemid", "(" . implode(", ", $items_id) . ")", "IN"), true); + + foreach (array_keys($items) as $cat_id) { + foreach (array_keys($items[$cat_id]) as $item_id) { + $item_obj =& $items_obj[$item_id]; + $items[$cat_id][$item_id] = array( + "title" => $item_obj->getVar("item_title"), + "uid" => $item_obj->getVar("uid"), + "link" => "view.item.php?itemid={$item_id}", + "time" => $item_obj->getVar("item_time"), + "tags" => tag_parse_tag($item_obj->getVar("item_tags", "n")), // optional + "content" => "", + ); + } + } + unset($items_obj); + } + +###Remove orphan tag-item links + function mymodule_tag_synchronization($mid) + { + // Optional + } + +###Get's category catid data for module +###Get item fields: catid, parentid, term + function mymodule_tag_category($catid) + { + return array('catid'->0, 'parentid' =>0, 'term' =>0); + } + +##Step 4: Display tags on our tiem page +These files are not explicit as filenames they could be different this is how to display the tag in the item of the module you are editing/writing. +###File: view.item.php + + include_once XOOPS_ROOT_PATH."/modules/tag/include/tagbar.php"; + $xoopsTpl->assign('tagbar', tagBar($itemid, $catid = 0)); + +###File: mymodule_item_template.html + + <{include file="db:tag_bar.html"}> + +##Step 5: create tag list page and tag view page and for categories as well +This is the files that belong in /modules/mymodule/xxxx.xxx.php for redirecting or displaying within your module the tag lists and views as well as categories +###File: list.tag.php + include "header.php"; + include XOOPS_ROOT_PATH . "/modules/tag/list.tag.php"; +###File: view.tag.php + include "header.php"; + include XOOPS_ROOT_PATH . "/modules/tag/view.tag.php"; +###File: list.cat.php + include "header.php"; + include XOOPS_ROOT_PATH . "/modules/tag/list.cat.php"; +###File: view.cat.php + include "header.php"; + include XOOPS_ROOT_PATH . "/modules/tag/view.cat.php"; + +##Step 6: create tag blocks +This is where you create the blocks you will have to edit and create files for this within your module +###File: xoops_version.php + + /* + * $options: + * $options[0] - number of tags to display + * $options[1] - time duration, in days, 0 for all the time + * $options[2] - max font size (px or %) + * $options[3] - min font size (px or %) + */ + $modversion["blocks"][] = array( + "file" => "mymodule_block_tag.php", + "name" => "Module Tag Cloud", + "description" => "Show tag cloud", + "show_func" => "mymodule_tag_block_cloud_show", + "edit_func" => "mymodule_tag_block_cloud_edit", + "options" => "100|0|150|80", + "template" => "mymodule_tag_block_cloud.html", + ); + + /* + * $options: + * $options[0] - number of tags to display + * $options[1] - time duration, in days, 0 for all the time + * $options[2] - sort: a - alphabet; c - count; t - time + */ + $modversion["blocks"][] = array( + "file" => "mymodule_block_tag.php", + "name" => "Module Top Tags", + "description" => "Show top tags", + "show_func" => "mymodule_tag_block_top_show", + "edit_func" => "mymodule_tag_block_top_edit", + "options" => "50|30|c", + "template" => "mymodule_tag_block_top.html", + ); + + /* + * $options: + */ + $modversion["blocks"][] = array( + "file" => "mymodule_block_cumulus.php", + "name" => "Module Top Tags", + "description" => "Show top tags", + "show_func" => "mymodule_tag_block_cumulus_show", + "edit_func" => "mymodule_tag_block_cumulus_edit", + "options" => "", + "template" => "mymodule_tag_block_cumulus.html", + ); +###File: mymodule_block_tag.php +This file belongs in /modules/mymodule/blocks and is adjustable in function names and filename in the xoops_version.php as seen in the example above. + + function mymodule_tag_block_cloud_show($options) + { + include_once XOOPS_ROOT_PATH . "/modules/tag/blocks/block.php"; + return tag_block_cloud_show($options, basename(dirname(dirname(dirname(__DIR__))))); + } + function mymodule_tag_block_cloud_edit($options) + { + include_once XOOPS_ROOT_PATH . "/modules/tag/blocks/block.php"; + return tag_block_cloud_edit($options); + } + function mymodule_tag_block_top_show($options) + { + include_once XOOPS_ROOT_PATH . "/modules/tag/blocks/block.php"; + return tag_block_top_show($options, basename(dirname(dirname(dirname(__DIR__))))); + } + function mymodule_tag_block_top_edit($options) + { + include_once XOOPS_ROOT_PATH . "/modules/tag/blocks/block.php"; + return tag_block_top_edit($options); + } + +###File: mymodule_block_cumulus.php +This file belongs in /modules/mymodule/blocks and is adjustable in function names and filename in the xoops_version.php as seen in the example above. + + function mymodule_tag_block_cumulus_show($options) + { + include_once XOOPS_ROOT_PATH . "/modules/tag/blocks/cumulus.php"; + return tag_block_cumulus_show($options, basename(dirname(dirname(dirname(__DIR__))))); + } + function mymodule_tag_block_cumulus_edit($options) + { + include_once XOOPS_ROOT_PATH . "/modules/tag/blocks/cumulus.php"; + return tag_block_cumulus_edit($options); + } + +###File: mymodule_tag_block_cloud.html +This file belongs in /modules/mymodule/templates/blocks and is adjustable in function names and filename in the xoops_version.php as seen in the example above. + + <{include file="db:tag_block_cloud.html"}> + +###File: mymodule_tag_block_top.html +This file belongs in /modules/mymodule/templates/blocks and is adjustable in function names and filename in the xoops_version.php as seen in the example above. + + <{include file="db:tag_block_top.html"}> + +###File: mymodule_tag_block_cumulus.html +This file belongs in /modules/mymodule/templates/blocks and is adjustable in function names and filename in the xoops_version.php as seen in the example above. + + <{include file="db:tag_block_cumulus.html"}> \ No newline at end of file Added: XoopsModules/tag/trunk/modules/tag/admin/admin.tag.php =================================================================== --- XoopsModules/tag/trunk/modules/tag/admin/admin.tag.php (rev 0) +++ XoopsModules/tag/trunk/modules/tag/admin/admin.tag.php 2017-05-23 05:09:37 UTC (rev 13242) @@ -0,0 +1,143 @@ +<?php +/** + * XOOPS tag management module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @author Taiwen Jiang <ph...@us...> + * @subpackage tag + * @description XOOPS tag management module + * @version 2.4.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/tag + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/tag + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/tag + * @link http://internetfounder.wordpress.com + */ + +include 'header.php'; +require_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; + +xoops_cp_header(); + +include XOOPS_ROOT_PATH . "/modules/tag/include/vars.php"; +echo function_exists("loadModuleAdminMenu") ? loadModuleAdminMenu(1) : ""; + +$limit = 10; +$modid = intval( empty($_GET['modid']) ? @$_POST['modid'] : $_GET['modid'] ); +$start = intval( empty($_GET['start']) ? @$_POST['start'] : $_GET['start'] ); +$status = intval( empty($_GET['status']) ? @$_POST['status'] : $_GET['status'] ); + +$tag_handler =& xoops_getmodulehandler("tag", $xoopsModule->getVar("dirname")); + +if (!empty($_POST['tags'])) { + foreach ($_POST['tags'] as $tag => $tag_status) { + $tag_obj =& $tag_handler->get($tag); + if (!is_object($tag_obj) || !$tag_obj->getVar("tag_id")) continue; + if ($tag_status < 0) { + $tag_handler->delete($tag_obj); + } elseif ($tag_status != $tag_obj->getVar("tag_status")) { + $tag_obj->setVar("tag_status", $tag_status); + $tag_handler->insert($tag_obj); + } + } + redirect_header("admin.tag.php?modid={$modid}&start={$start}&status={$status}", 2); + exit(); +} + +$sql = " SELECT tag_modid, COUNT(DISTINCT tag_id) AS count_tag"; +$sql .= " FROM " . $xoopsDB->prefix("tag_link"); +$sql .= " GROUP BY tag_modid"; +$counts_module = array(); +$module_list = array(); +if ( ($result = $xoopsDB->query($sql)) == false) { + xoops_error($xoopsDB->error()); +} else { + while ($myrow = $xoopsDB->fetchArray($result)) { + $counts_module[$myrow["tag_modid"]] = $myrow["count_tag"]; + } + if (!empty($counts_module)) { + $module_handler =& xoops_gethandler("module"); + $module_list = $module_handler->getList(new Criteria("mid", "(" . implode(", ", array_keys($counts_module)) . ")", "IN")); + } +} + +$opform = new XoopsSimpleForm('', 'moduleform', xoops_getenv("PHP_SELF"), "get"); +$tray = new XoopsFormElementTray(''); +$mod_select = new XoopsFormSelect(_SELECT, 'modid', $modid); +$mod_select->addOption(0, _ALL); +foreach ($module_list as $module => $module_name) { + $mod_select->addOption($module, $module_name." (" . $counts_module[$module] . ")"); +} +$tray->addElement($mod_select); +$status_select = new XoopsFormRadio("", 'status', $status); +$status_select->addOption(-1, _ALL); +$status_select->addOption(0, TAG_AM_ACTIVE); +$status_select->addOption(1, TAG_AM_INACTIVE); +$tray->addElement($status_select); +$tray->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit")); +$opform->addElement($tray); +$opform->display(); + +$criteria = new CriteriaCompo(); +$criteria->setSort("a"); +$criteria->setOrder("ASC"); +$criteria->setStart($start); +$criteria->setLimit($limit); +if ($status >= 0) { + $criteria->add( new Criteria("o.tag_status", $status) ); +} +if (!empty($modid)) { + $criteria->add( new Criteria("l.tag_modid", $modid) ); +} +$tags = $tag_handler->getByLimit($criteria, false); + +$form_tags = "<form name='tags' method='post' action='" . xoops_getenv("PHP_SELF") . "'>"; +$form_tags .= "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; +$form_tags .= "<tr align='center'>"; +$form_tags .= "<td class='bg3'>" . TAG_AM_TERM . "</td>"; +$form_tags .= "<td class='bg3' width='10%'>" . TAG_AM_ACTIVE . "</td>"; +$form_tags .= "<td class='bg3' width='10%'>" . TAG_AM_INACTIVE . "</td>"; +$form_tags .= "<td class='bg3' width='10%'>" . _DELETE . "</td>"; +$form_tags .= "</tr>"; +if (empty($tags)) { + $form_tags .= "<tr><td colspan='4'>" . _NONE . "</td></tr>"; +} else { + $class_tr = array("odd", "even"); + $i = 0; + foreach (array_keys($tags) as $key) { + $form_tags .= "<tr class='" . $class_tr[(++$i) % 2] . "'>"; + $form_tags .= "<td>" . $tags[$key]["term"] . "</td>"; + $form_tags .= "<td><input type='radio' name='tags[{$key}]' value='0' " . ( $tags[$key]["status"] ? "" : " 'checked' ") . "></td>"; + $form_tags .= "<td><input type='radio' name='tags[{$key}]' value='1' " . ( $tags[$key]["status"] ? " 'checked' " : "") . "></td>"; + $form_tags .= "<td><input type='radio' name='tags[{$key}]' value='-1'></td>"; + $form_tags .= "</tr>"; + } + if ( !empty($start) || count($tags) >= $limit ) { + $count_tag = $tag_handler->getCount($criteria); + + include XOOPS_ROOT_PATH . "/class/pagenav.php"; + $nav = new XoopsPageNav($count_tag, $limit, $start, "start", "modid={$modid}&status={$status}"); + $form_tags .= "<tr><td colspan='4' align='right'>" . $nav->renderNav(4) . "</td></tr>"; + } + $form_tags .= "<tr><td colspan='4' align='center'>"; + $form_tags .= "<input type='hidden' name='status' value='{$status}'> "; + $form_tags .= "<input type='hidden' name='start' value='{$start}'> "; + $form_tags .= "<input type='hidden' name='modid' value='{$modid}'> "; + $form_tags .= "<input type='submit' name='submit' value='" . _SUBMIT . "'> "; + $form_tags .= "<input type='reset' name='submit' value='" . _CANCEL . "'>"; + $form_tags .= "</td></tr>"; +} +$form_tags .= "</table>"; +$form_tags .= "</form>"; + +echo $form_tags; +xoops_cp_footer(); +?> \ No newline at end of file Added: XoopsModules/tag/trunk/modules/tag/admin/header.php =================================================================== --- XoopsModules/tag/trunk/modules/tag/admin/header.php (rev 0) +++ XoopsModules/tag/trunk/modules/tag/admin/header.php 2017-05-23 05:09:37 UTC (rev 13242) @@ -0,0 +1,91 @@ +<?php +/** + * XOOPS tag management module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @author Taiwen Jiang <ph...@us...> + * @subpackage tag + * @description XOOPS tag management module + * @version 2.4.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/tag + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/tag + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/tag + * @link http://internetfounder.wordpress.com + */ + +include "../../../include/cp_header.php"; +require XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->getVar("dirname") . "/include/vars.php"; +require_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->getVar("dirname") . "/include/functions.php"; +xoops_loadLanguage("main", $xoopsModule->getVar("dirname")); + +$myts =& MyTextSanitizer::getInstance(); + +IF (!@ include_once XOOPS_ROOT_PATH . "/Frameworks/art/functions.admin.php"): + +function loadModuleAdminMenu($currentoption, $breadcrumb = "") +{ + if (!$adminmenu = $GLOBALS["xoopsModule"]->getAdminMenu()) { + return false; + } + + $breadcrumb = empty($breadcrumb) ? $adminmenu[$currentoption]["title"] : $breadcrumb; + $module_link = XOOPS_URL . "/modules/" . $GLOBALS["xoopsModule"]->getVar("dirname") . "/"; + $image_link = XOOPS_URL . "/modules/" . $GLOBALS["xoopsModule"]->getVar("dirname") . "/images"; + + $adminmenu_text =' + <style type="text/css"> + <!-- + #buttontop { float:left; width:100%; background: #e7e7e7; font-size:93%; line-height:normal; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; margin: 0;} + #buttonbar { float:left; width:100%; background: #e7e7e7 url("'.$image_link.'/modadminbg.gif") repeat-x left bottom; font-size:93%; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; margin-bottom: 12px;} + #buttonbar ul { margin:0; margin-top: 15px; padding:10px 10px 0; list-style:none; } + #buttonbar li { display:inline; margin:0; padding:0; } + #buttonbar a { float:left; background:url("'.$image_link.'/left_both.gif") no-repeat left top; margin:0; padding:0 0 0 9px; border-bottom:1px solid #000; text-decoration:none; } + #buttonbar a span { float:left; display:block; background:url("'.$image_link.'/right_both.gif") no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; } + /* Commented Backslash Hack hides rule from IE5-Mac \*/ + #buttonbar a span {float:none;} + /* End IE5-Mac hack */ + #buttonbar a:hover span { color:#333; } + #buttonbar .current a { background-position:0 -150px; border-width:0; } + #buttonbar .current a span { background-position:100% -150px; padding-bottom:5px; color:#333; } + #buttonbar a:hover { background-position:0% -150px; } + #buttonbar a:hover span { background-position:100% -150px; } + //--> + </style> + <div id="buttontop"> + <table style="width: 100%; padding: 0; " cellspacing="0"> + <tr> + <td style="width: 70%; font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;"> + <a href="../index.php">' . $GLOBALS["xoopsModule"]->getVar("name") . '</a> + </td> + <td style="width: 30%; font-size: 10px; text-align: right; color: #2F5376; padding: 0 6px; line-height: 18px;"> + <strong>' . $GLOBALS["xoopsModule"]->getVar("name") . '</strong> ' . $breadcrumb . ' + </td> + </tr> + </table> + </div> + <div id="buttonbar"> + <ul> + '; + foreach (array_keys($adminmenu) as $key) { + $adminmenu_text .= (($currentoption == $key) ? '<li class="current">' : '<li>') . '<a href="' . $module_link . $adminmenu[$key]["link"] . '"><span>' . $adminmenu[$key]["title"] . '</span></a></li>'; + } + $adminmenu_text .= '<li><a href="' . XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $GLOBALS["xoopsModule"]->getVar("mid") . '"><span>' . _PREFERENCES . '</span></a></li>'; + $adminmenu_text .= ' + </ul> + </div> + <br style="clear:both;" />'; + + echo $adminmenu_text; +} + +ENDIF; +?> \ No newline at end of file Added: XoopsModules/tag/trunk/modules/tag/admin/index.php =================================================================== --- XoopsModules/tag/trunk/modules/tag/admin/index.php (rev 0) +++ XoopsModules/tag/trunk/modules/tag/admin/index.php 2017-05-23 05:09:37 UTC (rev 13242) @@ -0,0 +1,92 @@ +<?php +/** + * XOOPS tag management module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @author Taiwen Jiang <ph...@us...> + * @subpackage tag + * @description XOOPS tag management module + * @version 2.4.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/tag + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/tag + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/tag + * @link http://internetfounder.wordpress.com + */ + +include 'header.php'; + +xoops_cp_header(); + +include XOOPS_ROOT_PATH . "/modules/tag/include/vars.php"; +echo function_exists("loadModuleAdminMenu") ? loadModuleAdminMenu(0) : ""; + +$tag_handler =& xoops_getmodulehandler("tag", $xoopsModule->getVar("dirname")); +$count_tag = $tag_handler->getCount(); + +$count_item = 0; +$sql = " SELECT COUNT(DISTINCT tl_id) FROM " . $xoopsDB->prefix("tag_link"); +if ( ($result = $xoopsDB->query($sql)) == false) { + xoops_error($xoopsDB->error()); +} else { + list($count_item) = $xoopsDB->fetchRow($result); +} + +$sql = " SELECT tag_modid, SUM(tag_count) AS count_item, COUNT(DISTINCT tag_id) AS count_tag"; +$sql .= " FROM " . $xoopsDB->prefix("tag_stats"); +$sql .= " GROUP BY tag_modid"; +$counts_module = array(); +if( ($result = $xoopsDB->query($sql)) == false) { + xoops_error($xoopsDB->error()); +} else { + while ($myrow = $xoopsDB->fetchArray($result)) { + $counts_module[$myrow["tag_modid"]] = array("count_item" => $myrow["count_item"], "count_tag" => $myrow["count_tag"]); + } + if (!empty($counts_module)) { + $module_handler =& xoops_gethandler("module"); + $module_list = $module_handler->getList(new Criteria("mid", "(" . implode(", ", array_keys($counts_module)) . ")", "IN")); + } +} + +$output= " + <style type=\"text/css\"> + label,text { + display: block; + float: left; + margin-bottom: 2px; + } + label { + text-align: right; + width: 150px; + padding-right: 20px; + } + br { + clear: left; + } + </style> +"; + +$output .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . TAG_AM_STATS . "</legend>"; +$output .= "<div style='padding: 8px;'>"; +$output .= "<label><strong>" . TAG_AM_COUNT_TAG . ":</strong></label><text>" . $count_tag . "</text><br />"; +$output .= "<label><strong>" . TAG_AM_COUNT_ITEM . ":</strong></label><text>" . $count_item . "</text><br />"; +$output .= "</div>"; +$output .= "<div style='padding: 8px;'>"; +$output .= "<label><strong>" . TAG_AM_COUNT_MODULE . "</strong>:</label><text>" . TAG_AM_COUNT_TAG . " - " . TAG_AM_COUNT_ITEM . "</text><br />"; +foreach ($counts_module as $module => $count) { + $output .= "<label>" . $module_list[$module] . ":</label><text>" . $count["count_tag"] . " - " . $count["count_item"] . " [<a href=\"" . XOOPS_URL . "/modules/tag/admin/admin.tag.php?modid={$module}\">" . TAG_AM_EDIT . "</a>] [<a href=\"" . XOOPS_URL . "/modules/tag/admin/syn.tag.php?modid={$module}\">" . TAG_AM_SYNCHRONIZATION . "</a>] </text><br />"; +} +$output .= "</div>"; +$output .= "</fieldset>"; + +echo $output; +xoops_cp_footer(); +?> \ No newline at end of file Added: XoopsModules/tag/trunk/modules/tag/admin/menu.php =================================================================== --- XoopsModules/tag/trunk/modules/tag/admin/menu.php (rev 0) +++ XoopsModules/tag/trunk/modules/tag/admin/menu.php 2017-05-23 05:09:37 UTC (rev 13242) @@ -0,0 +1,38 @@ +<?php +/** + * XOOPS tag management module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @author Taiwen Jiang <ph...@us...> + * @subpackage tag + * @description XOOPS tag management module + * @version 2.4.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/tag + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/tag + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/tag + * @link http://internetfounder.wordpress.com + */ + + +if (!defined('XOOPS_ROOT_PATH')) { exit(); } + +global $adminmenu; + +$adminmenu = array(); + +$adminmenu[]= array("link" => "admin/index.php", + "title" => TAG_MI_ADMENU_INDEX); +$adminmenu[]= array("link" => "admin/admin.tag.php", + "title" => TAG_MI_ADMENU_EDIT); +$adminmenu[]= array("link" => "admin/syn.tag.php", + "title" => TAG_MI_ADMENU_SYNCHRONIZATION); +?> \ No newline at end of file Added: XoopsModules/tag/trunk/modules/tag/admin/syn.tag.php =================================================================== --- XoopsModules/tag/trunk/modules/tag/admin/syn.tag.php (rev 0) +++ XoopsModules/tag/trunk/modules/tag/admin/syn.tag.php 2017-05-23 05:09:37 UTC (rev 13242) @@ -0,0 +1,97 @@ +<?php +/** + * XOOPS tag management module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @author Taiwen Jiang <ph...@us...> + * @subpackage tag + * @description XOOPS tag management module + * @version 2.4.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/tag + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/tag + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/tag + * @link http://internetfounder.wordpress.com + */ + +include 'header.php'; +require_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; + +xoops_cp_header(); + +include XOOPS_ROOT_PATH . "/modules/tag/include/vars.php"; +echo function_exists("loadModuleAdminMenu") ? loadModuleAdminMenu(2) : ""; + +$limit = 10; +$modid = intval( @$_GET['modid'] ); +$start = intval( @$_GET['start'] ); +$limit = isset($_GET['limit']) ? intval( $_GET['limit'] ) : 100; + +$sql = " SELECT tag_modid, COUNT(DISTINCT tag_id) AS count_tag"; +$sql .= " FROM " . $xoopsDB->prefix("tag_link"); +$sql .= " GROUP BY tag_modid"; +$counts_module = array(); +$module_list = array(); +if ( $result = $xoopsDB->query($sql)) { + while ($myrow = $xoopsDB->fetchArray($result)) { + $counts_module[$myrow["tag_modid"]] = $myrow["count_tag"]; + } + if (!empty($counts_module)) { + $module_handler =& xoops_gethandler("module"); + $module_list = $module_handler->getList(new Criteria("mid", "(" . implode(", ", array_keys($counts_module)) . ")", "IN")); + } +} + +$opform = new XoopsSimpleForm('', 'moduleform', xoops_getenv("PHP_SELF"), "get"); +$tray = new XoopsFormElementTray(''); +$mod_select = new XoopsFormSelect(_SELECT, 'modid', $modid); +$mod_select->addOption(-1, TAG_AM_GLOBAL); +$mod_select->addOption(0, TAG_AM_ALL); +foreach ($module_list as $module => $module_name) { + $mod_select->addOption($module, $module_name . " (" . $counts_module[$module] . ")"); +} +$tray->addElement($mod_select); +$num_select = new XoopsFormSelect(TAG_AM_NUM, 'limit', $limit); +foreach (array(10, 50, 100, 500) as $_num) { + $num_select->addOption($_num); +} +$num_select->addOption(0, _ALL); +$tray->addElement($num_select); +$tray->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit")); +$tray->addElement(new XoopsFormHidden("start", $start)); +$opform->addElement($tray); +$opform->display(); + + +if ( isset($_GET['start']) ) { + + $tag_handler =& xoops_getmodulehandler("tag", $xoopsModule->getVar("dirname")); + + $criteria = new CriteriaCompo(); + $criteria->setStart($start); + $criteria->setLimit($limit); + if ($modid > 0) { + $criteria->add( new Criteria("l.tag_modid", $modid) ); + } + $tags = $tag_handler->getByLimit($criteria, false); + if (empty($tags)) { + echo "<h2>" . TAG_AM_FINISHED . "</h2>"; + } else { + + foreach (array_keys($tags) as $tag_id) { + $tag_handler->update_stats($tag_id, ( $modid == -1 ) ? 0 : $tags[$tag_id]["modid"]); + } + redirect_header("syn.tag.php?modid={$modid}&start=" . ($start + $limit) . "&limit={$limit}", 2, TAG_AM_IN_PROCESS); + } +} + +xoops_cp_footer(); +?> \ No newline at end of file Added: XoopsModules/tag/trunk/modules/tag/blocks/block.php =================================================================== --- XoopsModules/tag/trunk/modules/tag/blocks/block.php (rev 0) +++ XoopsModules/tag/trunk/modules/tag/blocks/block.php 2017-05-23 05:09:37 UTC (rev 13242) @@ -0,0 +1,307 @@ +<?php +/** + * XOOPS tag management module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @author Taiwen Jiang <ph...@us...> + * @subpackage tag + * @description XOOPS tag management module + * @version 2.4.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/tag + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/tag + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/tag + * @link http://internetfounder.wordpress.com + */ + + +if (!defined('XOOPS_ROOT_PATH')) { exit(); } +include XOOPS_ROOT_PATH . "/modules/tag/include/vars.php"; +include_once XOOPS_ROOT_PATH . "/modules/tag/include/functions.php"; + +xoops_loadLanguage("blocks", "tag"); + +/**#@+ + * Function to display tag cloud + * + * Developer guide: + * <ul> + * <li>Build your tag_block_cloud_show function, for example newbb_block_tag_cloud_show;</li> + * <li>Call the tag_block_cloud_show in your defined block function:<br /> + * <code> + * function newbb_block_tag_cloud_show($options) { + * $catid = $options[4]; // Not used by newbb, Only for demonstration + * if (!@include_once XOOPS_ROOT_PATH."/modules/tag/blocks/block.php") { + * return null; + * } + * $block_content = tag_block_cloud_show($options, "newbb", $catid); + * return $block_content; + * } + * </code> + * </li> + * <li>Build your tag_block_cloud_edit function, for example newbb_block_tag_cloud_edit;</li> + * <li>Call the tag_block_cloud_edit in your defined block function:<br /> + * <code> + * function newbb_block_tag_cloud_edit($options) { + * if (!@include_once XOOPS_ROOT_PATH."/modules/tag/blocks/block.php") { + * return null; + * } + * $form = tag_block_cloud_edit($options); + * $form .= $CODE_FOR_GET_CATID; // Not used by newbb, Only for demonstration + * return $form; + * } + * </code> + * </li> + * <li>Create your tag_block_cloud template, for example newbb_block_tag_cloud.html;</li> + * <li>Include tag_block_cloud template in your created block template:<br /> + * <code> + * <{include file="db:tag_block_cloud.html"}> + * </code> + * </li> + * </ul> + * + * {@link TagTag} + * + * @param array $options: + * $options[0] - number of tags to display + * $options[1] - time duration, in days, 0 for all the time + * $options[2] - max font size (px or %) + * $options[3] - min font size (px or %) + */ +function tag_block_cloud_show( $options, $dirname = "", $catid = 0 ) +{ + global $xoopsDB; + + if (empty($dirname)) { + $modid = 0; + } elseif (isset($GLOBALS["xoopsModule"]) && is_object($GLOBALS["xoopsModule"]) && $GLOBALS["xoopsModule"]->getVar("dirname") == $dirname) { + $modid = $GLOBALS["xoopsModule"]->getVar("mid"); + } else { + $module_handler =& xoops_gethandler("module"); + $module = $module_handler->getByDirname($dirname); + $modid = $module->getVar("mid"); + } + + $block = array(); + $tag_handler =& xoops_getmodulehandler("tag", "tag"); + tag_define_url_delimiter(); + + $criteria = new CriteriaCompo(); + $criteria->setSort("count"); + $criteria->setOrder("DESC"); + $criteria->setLimit($options[0]); + $criteria->add( new Criteria("o.tag_status", 0) ); + if (!empty($modid)) { + $criteria->add( new Criteria("l.tag_modid", $modid) ); + if ($catid >= 0) { + $criteria->add( new Criteria("l.tag_catid", $catid) ); + } + } + if (!$tags = $tag_handler->getByLimit($criteria, empty($options[1]))) { + return $block; + } + + $count_max = 0; + $count_min = 0; + $tags_term = array(); + foreach (array_keys($tags) as $key) { + if ($tags[$key]["count"] > $count_max) $count_max = $tags[$key]["count"]; + if ($tags[$key]["count"] < $count_min || $count_min == 0) $count_min = $tags[$key]["count"]; + $tags_term[] = strtolower($tags[$key]["term"]); + } + array_multisort($tags_term, SORT_ASC, $tags); + $count_interval = $count_max - $count_min; + $level_limit = 5; + + $font_max = $options[2]; + $font_min = $options[3]; + $font_ratio = ($count_interval) ? ($font_max - $font_min) / $count_interval : 1; + + $tags_data = array(); + foreach (array_keys($tags) as $key) { + $tags_data[] = array( + "id" => $tags[$key]["id"], + "font" => ($count_interval) ? floor( ($tags[$key]["count"] - $count_min) * $font_ratio + $font_min ) : 100, + "level" => empty($count_max) ? 0 : floor( ($tags[$key]["count"] - $count_min) * $level_limit / $count_max ), + "term" => $tags[$key]["term"], + "count" => $tags[$key]["count"], + ); + } + unset($tags, $tags_term); + + $block["tags"] =& $tags_data; + $block["tag_dirname"] = "tag"; + if (!empty($modid)) { + $module_handler =& xoops_gethandler('module'); + if ($module_obj =& $module_handler->get($modid)) { + $block["tag_dirname"] = $module_obj->getVar("dirname"); + } + } + return $block; +} + +function tag_block_cloud_edit($options) +{ + $form = TAG_MB_ITEMS . ": <input type=\"text\" name=\"options[0]\" value=\"" . $options[0] . "\" /><br />"; + $form .= TAG_MB_TIME_DURATION . ": <input type=\"text\" name=\"options[1]\" value=\"" . $options[1] . "\" /><br />"; + $form .= TAG_MB_FONTSIZE_MAX . ": <input type=\"text\" name=\"options[2]\" value=\"" . $options[2] . "\" /><br />"; + $form .= TAG_MB_FONTSIZE_MIN . ": <input type=\"text\" name=\"options[3]\" value=\"" . $options[3] . "\" /><br />"; + + return $form; +} + + +/**#@+ + * Function to display top tag list + * + * Developer guide: + * <ul> + * <li>Build your tag_block_top_show function, for example newbb_block_tag_top_show;</li> + * <li>Call the tag_block_top_show in your defined block function:<br /> + * <code> + * function newbb_block_tag_top_show($options) { + * $catid = $options[3]; // Not used by newbb, Only for demonstration + * if (!@include_once XOOPS_ROOT_PATH."/modules/tag/blocks/block.php") { + * return null; + * } + * $block_content = tag_block_top_show($options, "newbb", $catid); + * return $block_content; + * } + * </code> + * </li> + * <li>Build your tag_block_top_edit function, for example newbb_block_tag_top_edit;</li> + * <li>Call the tag_block_top_edit in your defined block function:<br /> + * <code> + * function newbb_block_tag_top_edit($options) { + * if (!@include_once XOOPS_ROOT_PATH."/modules/tag/blocks/block.php") { + * return null; + * } + * $form = tag_block_cloud_edit($options); + * $form .= $CODE_FOR_GET_CATID; // Not used by newbb, Only for demonstration + * return $form; + * } + * </code> + * </li> + * <li>Create your tag_block_top template, for example newbb_block_tag_top.html;</li> + * <li>Include tag_block_top template in your created block template:<br /> + * <code> + * <{include file="db:tag_block_top.html"}> + * </code> + * </li> + * </ul> + * + * {@link TagTag} + * + * @param array $options: + * $options[0] - number of tags to display + * $options[1] - time duration, in days, 0 for all the time + * $options[2] - sort: a - alphabet; c - count; t - time + */ +function tag_block_top_show( $options, $dirname = "", $catid = 0 ) +{ + global $xoopsDB; + + if (empty($dirname)) { + $modid = 0; + } elseif (isset($GLOBALS["xoopsModule"]) && is_object($GLOBALS["xoopsModule"]) && $GLOBALS["xoopsModule"]->getVar("dirname") == $dirname) { + $modid = $GLOBALS["xoopsModule"]->getVar("mid"); + } else { + $module_handler =& xoops_gethandler("module"); + $module = $module_handler->getByDirname($dirname); + $modid = $module->getVar("mid"); + } + + $block = array(); + $tag_handler =& xoops_getmodulehandler("tag", "tag"); + tag_define_url_delimiter(); + + $criteria = new CriteriaCompo(); + $sort = ($options[2] == "a" || $options[2] == "alphabet") ? "count" : $options[2]; + $criteria->setSort("count"); + $criteria->setOrder("DESC"); + $criteria->setLimit($options[0]); + $criteria->add( new Criteria("o.tag_status", 0) ); + if (!empty($options[1])) { + $criteria->add( new Criteria("l.tag_time", time() - $options[1] * 24 * 3600, ">") ); + } + if (!empty($modid)) { + $criteria->add( new Criteria("l.tag_modid", $modid) ); + if ($catid >= 0) { + $criteria->add( new Criteria("l.tag_catid", $catid) ); + } + } + if (!$tags = $tag_handler->getByLimit($criteria, empty($options[1]))) { + return $block; + } + + $count_max = 0; + $count_min = 0; + $tags_sort = array(); + foreach (array_keys($tags) as $key) { + if ($tags[$key]["count"] > $count_max) $count_max = $tags[$key]["count"]; + if ($tags[$key]["count"] < $count_min) $count_min = $tags[$key]["count"]; + if ($options[2] == "a" || $options[2] == "alphabet") { + $tags_sort[] = strtolower($tags[$key]["term"]); + } + } + $count_interval = $count_max - $count_min; + + /* + $font_max = $options[1]; + $font_min = $options[2]; + $font_ratio = ($count_interval) ? ($font_max - $font_min) / $count_interval : 1; + */ + if (!empty($tags_sort)) { + array_multisort($tags_sort, SORT_ASC, $tags); + } + + $tags_data = array(); + foreach (array_keys($tags) as $key) { + $tags_data[] = array( + "id" => $tags[$key]["id"], + //"level" => ($tags[$key]["count"] - $count_min) * $font_ratio + $font_min, + "term" => $tags[$key]["term"], + "count" => $tags[$key]["count"], + ); + } + unset($tags, $tags_term); + + $block["tags"] =& $tags_data; + $block["tag_dirname"] = "tag"; + if (!empty($modid)) { + $module_handler =& xoops_gethandler('module'); + if ($module_obj =& $module_handler->get($modid)) { + $block["tag_dirname"] = $module_obj->getVar("dirname"); + } + } + return $block; +} + +function tag_block_top_edit($options) +{ + $form = TAG_MB_ITEMS . ": <input type=\"text\" name=\"options[0]\" value=\"" . $options[0] . "\" /><br />"; + $form .= TAG_MB_TIME_DURATION . ": <input type=\"text\" name=\"options[1]\" value=\"" . $options[1] . "\" /><br />"; + $form .= TAG_MB_SORT . ": <select name='options[2]'>"; + $form .= "<option value='a'"; + if ($options[2] == "a") $form .= " selected='selected' "; + $form .= ">" . TAG_MB_ALPHABET . "</option>"; + $form .= "<option value='c'"; + if ($options[2] == "c") $form .= " selected='selected' "; + $form .= ">" . TAG_MB_COUNT . "</option>"; + $form .= "<option value='t'"; + if ($options[2] == "t") $form .= " selected='selected' "; + $form .= ">" . TAG_MB_TIME . "</option>"; + $form .= "</select>"; + + return $form; +} + +?> \ No newline at end of file Added: XoopsModules/tag/trunk/modules/tag/blocks/index.html =================================================================== Added: XoopsModules/tag/trunk/modules/tag/class/index.html =================================================================== Added: XoopsModules/tag/trunk/modules/tag/class/link.php =================================================================== --- XoopsModules/tag/trunk/modules/tag/class/link.php (rev 0) +++ XoopsModules/tag/trunk/modules/tag/class/link.php 2017-05-23 05:09:37 UTC (rev 13242) @@ -0,0 +1,81 @@ +<?php +/** + * XOOPS tag management module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @author Taiwen Jiang <ph...@us...> + * @subpackage tag + * @description XOOPS tag management module + * @version 2.4.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/tag + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/tag + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/tag + * @link http://internetfounder.wordpress.com + */ + +if (!defined("XOOPS_ROOT_PATH")) { + exit(); +} + +class TagLink extends XoopsObject +{ + /** + * Constructor + */ + function TagLink() + { + $this->initVar("tl_id", XOBJ_DTYPE_INT, null, false); + $this->initVar("tag_id", XOBJ_DTYPE_INT, 0); + $this->initVar("tag_modid", XOBJ_DTYPE_INT, 0); + $this->initVar("tag_catid", XOBJ_DTYPE_INT, 0); + $this->initVar("tag_itemid", XOBJ_DTYPE_INT, 0); + $this->initVar("tag_time", XOBJ_DTYPE_INT, 0); + } +} + +/** + * Tag link handler class. + * @package tag + * + * @author Taiwen Jiang <ph...@us...> + * @copyright copyright © The XOOPS Project + * + * {@link XoopsPersistableObjectHandler} + * + */ + +class TagLinkHandler extends XoopsPersistableObjectHandler +{ + var $table_stats; + + /** + * Constructor + * + * @param object $db reference to the {@link XoopsDatabase} object + **/ + function TagLinkHandler(&$db) + { + $this->XoopsPersistableObjectHandler($db, "tag_link", "TagLink", "tl_id", "tag_itemid"); + $this->table_stats = $this->db->prefix("tag_stats"); + } + + /** + * clean orphan links from database + * + * @return bool true on success + */ + function cleanOrphan() + { + return parent::cleanOrphan($this->db->prefix("tag_tag"), "tag_id"); + } +} +?> \ No newline at end of file Added: XoopsModules/tag/trunk/modules/tag/class/tag.php =================================================================== --- XoopsModules/tag/trunk/modules/tag/class/tag.php (rev 0) +++ XoopsModules/tag/trunk/modules/tag/class/tag.php 2017-05-23 05:09:37 UTC (rev 13242) @@ -0,0 +1,543 @@ +<?php +/** + * XOOPS tag management module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @author Taiwen Jiang <ph...@us...> + * @subpackage tag + * @description XOOPS tag management module + * @version 2.4.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/tag + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/tag + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/tag + * @link http://internetfounder.wordpress.com + */ + + +if (!defined("XOOPS_ROOT_PATH")) { + exit(); +} + +class TagTag extends XoopsObject +{ + /** + * Constructor + * + * @param int $id ID of the tag, deprecated + */ + function TagTag($id = null) + { + $this->initVar("tag_id", XOBJ_DTYPE_INT, null, false); + $this->initVar("tag_term", XOBJ_DTYPE_TXTBOX, "", true); + $this->initVar("tag_status", XOBJ_DTYPE_INT, 0); + $this->initVar("tag_count", XOBJ_DTYPE_INT, 0); + } +} + +/** + * Tag object handler class. + * + * @author Taiwen Jiang <ph...@us...> + * @copyright copyright © The XOOPS Project + * + * {@link XoopsPersistableObjectHandler} + * + */ + +class TagTagHandler extends XoopsPersistableObjectHandler +{ + var $table_link; + var $table_stats; + + /** + * Constructor + * + * @param object $db reference to the {@link XoopsDatabase} object + **/ + function TagTagHandler(&$db) + { + $this->XoopsPersistableObjectHandler($db, "tag_tag", "TagTag", "tag_id", "tag_term"); + $this->table_link = $this->db->prefix("tag_link"); + $this->table_stats = $this->db->prefix("tag_stats"); + } + + /** + * Get tags linked to an item + * + * @param integer $itemid item ID + * @param integer $modid module ID, optional + * @param integer $catid id of corresponding category, optional + * @return array associative array of tags (id, term) + */ + function getByItem($itemid, $modid = 0, $catid = 0) + { + $ret = array(); + + $itemid = intval($itemid); + $modid = (empty($modid) && is_object($GLOBALS["xoopsModule"]) && "tag" != $GLOBALS["xoopsModule"]->getVar("dirname") ) ? $GLOBALS["xoopsModule"]->getVar("mid") : intval($modid); + if (empty($itemid) || empty($modid)) return $ret; + + $sql = "SELECT o.tag_id, o.tag_term" . + " FROM {$this->table_link} AS l " . + " LEFT JOIN {$this->table} AS o ON o.{$this->keyName} = l.{$this->keyName} " . + " WHERE l.tag_itemid = {$itemid} AND l.tag_modid = {$modid}" . + (empty($catid) ? "" : ( " AND l.tag_catid=" . intval($catid))) . + " ORDER BY o.tag_count DESC" + ; + if ( ($result = $this->db->query($sql)) == false) { + return $ret; + } + while ($myrow = $this->db->fetchArray($result)) { + $ret[$myrow[$this->keyName]] = $myrow["tag_term"]; + } + return $ret; + } + + /** + * Update tags linked to an item + * + * @param array $tags + * @param integer $itemid item ID + * @param integer $modid module ID or module dirname, optional + * @param integer $catid id of corresponding category, optional + * @return boolean + */ + function updateByItem($tags, $itemid, $modid = "", $catid = 0) + { + $catid = intval($catid); + $itemid = intval($itemid); + + if (!empty($modid) && !is_numeric($modid)) { + if (is_object($GLOBALS["xoopsModule"]) && $modid == $GLOBALS["xoopsModule"]->getVar("dirname") ) { + $modid = $GLOBALS["xoopsModule"]->getVar("mid"); + } else { + $module_handler =& xoops_gethandler("module"); + if ($module_obj = $module_handler->getByDirname($modid)) { + $modid = $module_obj->getVar("mid"); + } else { + $modid = 0; + } + } + } elseif (is_object($GLOBALS["xoopsModule"])) { + $modid = $GLOBALS["xoopsModule"]->getVar("mid"); + } + + if (empty($itemid) || empty($modid)) return false; + + if (empty($tags)) { + $tags = array(); + } elseif (!is_array($tags)) { + include_once XOOPS_ROOT_PATH . "/modules/tag/include/functions.php"; + $tags = tag_parse_tag(addslashes(stripslashes($tags))); + } + + $tags_existing = $this->getByItem($itemid, $modid, $catid); + $tags_delete = array_diff(array_values($tags_existing), $tags); + $tags_add = array_diff($tags, array_values($tags_existing)); + + $tags_update = array(); + + if (!empty($tags_delete)) { + $tags_delete = array_map(array($this->db, "quoteString"), $tags_delete); + if ($tags_id = $this->getIds(new Criteria("tag_term", "(" . implode(", ", $tags_delete) . ")", "IN"))) { + $sql = "DELETE FROM {$this->table_link}" . + " WHERE " . + " {$this->keyName} IN (" . implode(", ", $tags_id) . ")" . + " AND tag_modid = {$modid} AND tag_catid = {$catid} AND tag_itemid = {$itemid}"; + if ( ($result = $this->db->queryF($sql)) == false) { + } + $sql = "DELETE FROM " . $this->table . + " WHERE ". + " tag_count < 2 AND ". + " {$this->keyName} IN (" . implode(", ", $tags_id) . ")"; + ... [truncated message content] |