diff --git a/css/admin_style.css b/css/admin_style.css index 2e1f37a..64994e3 100755 --- a/css/admin_style.css +++ b/css/admin_style.css @@ -182,4 +182,8 @@ position: absolute; top: 0; left: 0; +} + +.mugshot-hidden-while-selecting { + display: none !important; } \ No newline at end of file diff --git a/include/helpers.php b/include/helpers.php new file mode 100644 index 0000000..07989b2 --- /dev/null +++ b/include/helpers.php @@ -0,0 +1,108 @@ + \ No newline at end of file diff --git a/js/admin_mug.js b/js/admin_mug.js index f6cc609..9cb7d18 100755 --- a/js/admin_mug.js +++ b/js/admin_mug.js @@ -414,6 +414,7 @@ function beginCapture(e) { MugShot.selecting = true; MugShot.img.addEventListener('mousemove', updateCapture); MugShot.img.addEventListener('mouseup', haltCapture); + // left top height width var frame = { 'lft': e.pageX - MugShot.offset.left, @@ -421,9 +422,17 @@ function beginCapture(e) { 'height': 5, 'width': 5, }; + MugShot.createBoundingBox(frame); - // MugShot.createBoundingBox(e.pageX - MugShot.offset.left, e.pageY - MugShot.offset.top, 5, 5); + + // Hide all the frames while we select the new one. Keeps them from interfering. + for (let index = 0; index < MugShot.mugs.length - 1; index++) { + MugShot.mugs[index].frame.el.classList.toggle('mugshot-hidden-while-selecting'); + MugShot.mugs[index].name.el.classList.toggle('mugshot-hidden-while-selecting'); + } + MugShot.mugs[MugShot.cfi].frame.el.classList.toggle('mugshot-active'); + MugShot.toggleSubmitBtn('on'); } } @@ -441,6 +450,13 @@ function haltCapture(e) { MugShot.img.removeEventListener('mouseup', haltCapture, false); MugShot.mugs[MugShot.cfi].frame.el.ondblclick = updateBoundingBox; MugShot.mugs[MugShot.cfi].frame.el.classList.toggle('mugshot-mousetrap'); + + // Done capturing so re-show the other mugshot frames + for (let index = 0; index < MugShot.mugs.length - 1; index++) { + MugShot.mugs[index].frame.el.classList.toggle('mugshot-hidden-while-selecting'); + MugShot.mugs[index].name.el.classList.toggle('mugshot-hidden-while-selecting'); + } + var pos = MugShot.setBoundingBoxPosition(e.pageX - MugShot.offset.left, e.pageY - MugShot.offset.top); MugShot.mugs[MugShot.cfi].frame.left = pos[0]; MugShot.mugs[MugShot.cfi].frame.top = pos[1]; diff --git a/language/en_UK/plugin.lang.php b/language/en_UK/plugin.lang.php index 0dcc4db..bca31ef 100755 --- a/language/en_UK/plugin.lang.php +++ b/language/en_UK/plugin.lang.php @@ -27,3 +27,7 @@ $lang['Groups'] = 'Groups'; $lang['Type in a search term'] = 'Type in a search term'; $lang['The following groups can use MugShot to tag people'] = 'The following groups can use MugShot to tag people'; +$lang['MugShot to crop tagged faces from photos'] = 'MugShot to crop tagged faces from photos'; +$lang['ALLOW'] = 'ALLOW'; +$lang['DO NOT ALLOW'] = 'DO NOT ALLOW'; +$lang['Maximum number of tags to load client side for auto complete functionality'] = 'Maximum number of tags to load client side for auto complete functionality'; \ No newline at end of file diff --git a/language/en_US/plugin.lang.php b/language/en_US/plugin.lang.php index 0dcc4db..bca31ef 100755 --- a/language/en_US/plugin.lang.php +++ b/language/en_US/plugin.lang.php @@ -27,3 +27,7 @@ $lang['Groups'] = 'Groups'; $lang['Type in a search term'] = 'Type in a search term'; $lang['The following groups can use MugShot to tag people'] = 'The following groups can use MugShot to tag people'; +$lang['MugShot to crop tagged faces from photos'] = 'MugShot to crop tagged faces from photos'; +$lang['ALLOW'] = 'ALLOW'; +$lang['DO NOT ALLOW'] = 'DO NOT ALLOW'; +$lang['Maximum number of tags to load client side for auto complete functionality'] = 'Maximum number of tags to load client side for auto complete functionality'; \ No newline at end of file diff --git a/main.inc.php b/main.inc.php index 40982a6..2945fca 100755 --- a/main.inc.php +++ b/main.inc.php @@ -35,6 +35,10 @@ add_event_handler('loc_begin_page_header', 'mugshot_files', 40, 2); add_event_handler('loc_end_picture', 'mugshot_button'); +/* + * Include custom helper functions + */ +include_once(MUGSHOT_PATH . 'include/helpers.php'); /* * Conditional Logic for groups @@ -84,28 +88,6 @@ } -/* - * Fetches Sql - */ -function fetch_sql($sql, $col, $ser) { - $result = pwg_query($sql); - - while ($row = pwg_db_fetch_assoc($result)) { - $data[] = $row; - } - - if (!isset($data)) { - $data = 0; - } else { - if($col !== false) { - $data = array_column($data, $col); - } - } - - return ($ser) ? json_encode($data) : $data; -} - - /* * Loads translations */ @@ -161,8 +143,8 @@ function query_mugshot_groups() { /* * Queries all tags in database */ -function defined_tags() { - $sql = 'SELECT name FROM ' . TAGS_TABLE . ' ORDER BY lastmodified ASC LIMIT 100;'; +function defined_tags($max_tags) { + $sql = 'SELECT name FROM ' . TAGS_TABLE . " ORDER BY lastmodified ASC LIMIT $max_tags;"; $x = fetch_sql($sql, 'name', false); @@ -253,10 +235,14 @@ function insert_tag_list() { global $template; + $plugin_config = unserialize(conf_get_param(MUGSHOT_ID)); + + $max_tags = $plugin_config['max_tags'] ?? 500; + /* * Array of tags */ - $template -> assign('MUGSHOT_TAG_LIST', defined_tags()); + $template -> assign('MUGSHOT_TAG_LIST', defined_tags($max_tags)); /* * Specify the tag list template file diff --git a/maintain.inc.php b/maintain.inc.php index dfd8560..f087885 100755 --- a/maintain.inc.php +++ b/maintain.inc.php @@ -2,6 +2,16 @@ defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); +/* + * Plugin Constants + */ +defined('MUGSHOT_ID') or define('MUGSHOT_ID', basename(dirname(__FILE__))); +defined('MUGSHOT_PATH') or define('MUGSHOT_PATH' , PHPWG_PLUGINS_PATH . MUGSHOT_ID . '/'); + +/* + * Include custom helper functions + */ +include_once(MUGSHOT_PATH . 'include/helpers.php'); /** * This class is used to expose maintenance methods to the plugins manager @@ -26,31 +36,14 @@ function __construct($plugin_id) */ function install($plugin_version, &$errors=array()) { - $configQuery = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("MugShot","","MugShot configuration values");'; - - $createTableQuery = 'CREATE TABLE IF NOT EXISTS `face_tag_positions` ( - `image_id` mediumint(8) unsigned NOT NULL default "0", - `tag_id` smallint(5) unsigned NOT NULL default "0", - `top` float unsigned NOT NULL default "0", - `lft` float unsigned NOT NULL default "0", - `width` float unsigned NOT NULL default "0", - `height` float unsigned NOT NULL default "0", - `image_width` float unsigned NOT NULL default "0", - `image_height` float unsigned NOT NULL default "0", - PRIMARY KEY (`image_id`,`tag_id`) - )'; - - $deleteTriggerQuery = "DROP TRIGGER IF EXISTS `sync_mug_shot`;"; + // Create the table to store face vector information + create_facetag_table(); - $makeTriggerQuery = "CREATE TRIGGER `sync_mug_shot` - AFTER DELETE ON ".TAGS_TABLE." - FOR EACH ROW DELETE FROM face_tag_positions - WHERE face_tag_positions.tag_id = old.id"; + // Create the trigger to automatically clean tag references when tags are removed. + create_tag_drop_trigger(); - pwg_query($configQuery); - pwg_query($createTableQuery); - pwg_query($deleteTriggerQuery); - pwg_query($makeTriggerQuery); + // Create the tagging user group and associate the current user. + create_tag_group(); $this->installed = true; } @@ -58,6 +51,7 @@ function install($plugin_version, &$errors=array()) function deactivate() { // Do nothing + create_tag_group(); } function update($old_version, $new_version, &$errors=array()) diff --git a/template/admin.tpl b/template/admin.tpl index 7eceb4c..622a216 100755 --- a/template/admin.tpl +++ b/template/admin.tpl @@ -15,6 +15,14 @@ input[type="radio"] { margin-right: 10px; } +.tagbox { + width:581px; + height:1.25em; + padding:5px 8px 2px; + border:1px solid #787777a6; + margin-right:25px; + background: white; +} {/literal}{/html_style} {combine_script id='LocalStorageCache' load='footer' path='admin/themes/default/js/LocalStorageCache.js'} @@ -57,17 +65,23 @@ jQuery(document).ready(function() { {/if}

+


+

+