Esempio n. 1
0
function unaliasTags($tags)
{
    $aliases = getAliasTags($tags);
    if ($aliases) {
        $tags = array_flip(array_merge($tags, $aliases));
        foreach ($aliases as $alias => $tag) {
            unset($tags[$alias]);
        }
        $tags = array_values(array_flip($tags));
    }
    return $tags;
}
Esempio n. 2
0
<?php

require 'inc.bootstrap.php';
$aliases = getAliasTags();
$aliases[''] = '';
// Save aliases
if (isset($_POST['source'], $_POST['target'])) {
    // echo '<pre>';
    // print_r($_POST);
    // Prepare from _POST
    $inserts = array();
    foreach ($_POST['source'] as $i => $source) {
        $target = @$_POST['target'][$i];
        if ($source && $target) {
            $exists = $db->select_one('l_tags', 'id', array('tag' => $source));
            if ($exists) {
                exit('<p>&quot;' . html($source) . "&quot; is an existing tag. You can't create it as an alias!</p>");
            }
            $targetTagId = $db->select_one('l_tags', 'id', array('tag' => $target));
            if ($targetTagId) {
                $inserts[] = array('alias' => $source, 'tag_id' => $targetTagId);
            } else {
                exit('<p>&quot;' . html($target) . "&quot; isn't a valid target tag. It no existo!</p>");
            }
        }
    }
    // print_r($inserts);
    // Update db
    if ($inserts) {
        $db->begin();
        $db->delete('l_aliases', '1');