Пример #1
0
/**
 * Deletes all tags linked to no photo
 */
function delete_orphan_tags()
{
    $orphan_tags = get_orphan_tags();
    if (count($orphan_tags) > 0) {
        $orphan_tag_ids = array();
        foreach ($orphan_tags as $tag) {
            $orphan_tag_ids[] = $tag['id'];
        }
        delete_tags($orphan_tag_ids);
    }
}
Пример #2
0
    $ret = create_tag($_POST['add_tag']);
    if (isset($ret['error'])) {
        $page['errors'][] = $ret['error'];
    } else {
        $page['infos'][] = $ret['info'];
    }
}
// +-----------------------------------------------------------------------+
// |                             template init                             |
// +-----------------------------------------------------------------------+
$template->set_filenames(array('tags' => 'tags.tpl'));
$template->assign(array('F_ACTION' => PHPWG_ROOT_PATH . 'admin.php?page=tags', 'PWG_TOKEN' => get_pwg_token()));
// +-----------------------------------------------------------------------+
// |                              orphan tags                              |
// +-----------------------------------------------------------------------+
$orphan_tags = get_orphan_tags();
$orphan_tag_names = array();
foreach ($orphan_tags as $tag) {
    $orphan_tag_names[] = trigger_change('render_tag_name', $tag['name'], $tag);
}
if (count($orphan_tag_names) > 0) {
    $page['warnings'][] = sprintf(l10n('You have %d orphan tags: %s.') . ' <a href="%s">' . l10n('Delete orphan tags') . '</a>', count($orphan_tag_names), implode(', ', $orphan_tag_names), get_root_url() . 'admin.php?page=tags&amp;action=delete_orphans&amp;pwg_token=' . get_pwg_token());
}
// +-----------------------------------------------------------------------+
// |                             form creation                             |
// +-----------------------------------------------------------------------+
// tag counters
$query = '
SELECT tag_id, COUNT(image_id) AS counter
  FROM ' . IMAGE_TAG_TABLE . '
  GROUP BY tag_id';