Esempio n. 1
0
File: add.php Progetto: oki34/eztags
    $newKeyword = trim($http->postVariable('TagEditKeyword', ''));
    if (empty($newKeyword)) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Name cannot be empty.');
    }
    if (empty($error) && eZTagsObject::exists(0, $newKeyword, $parentTag instanceof eZTagsObject ? $parentTag->attribute('id') : 0)) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Tag/synonym with that translation already exists in selected location.');
    }
    if (empty($error)) {
        $db = eZDB::instance();
        $db->begin();
        $languageMask = eZContentLanguage::maskByLocale(array($language->attribute('locale')), $http->hasPostVariable('AlwaysAvailable'));
        $tag = new eZTagsObject(array('parent_id' => $parentTagID, 'main_tag_id' => 0, 'depth' => $parentTag instanceof eZTagsObject ? $parentTag->attribute('depth') + 1 : 1, 'path_string' => $parentTag instanceof eZTagsObject ? $parentTag->attribute('path_string') : '/', 'main_language_id' => $language->attribute('id'), 'language_mask' => $languageMask), $language->attribute('locale'));
        $tag->store();
        $translation = new eZTagsKeyword(array('keyword_id' => $tag->attribute('id'), 'language_id' => $language->attribute('id'), 'keyword' => $newKeyword, 'locale' => $language->attribute('locale'), 'status' => eZTagsKeyword::STATUS_PUBLISHED));
        if ($http->hasPostVariable('AlwaysAvailable')) {
            $translation->setAttribute('language_id', $translation->attribute('language_id') + 1);
        }
        $translation->store();
        $tag->setAttribute('path_string', $tag->attribute('path_string') . $tag->attribute('id') . '/');
        $tag->store();
        $tag->updateModified();
        /* Extended Hook */
        if (class_exists('ezpEvent', false)) {
            ezpEvent::getInstance()->filter('tag/add', array('tag' => $tag, 'parentTag' => $parentTag));
        }
        $db->commit();
        return $Module->redirectToView('id', array($tag->attribute('id')));
    }
}
$tpl = eZTemplate::factory();
$tpl->setVariable('parent_id', $parentTagID);
Esempio n. 2
0
if (!$tag instanceof eZTagsObject) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
$error = '';
if ($http->hasPostVariable('SaveButton')) {
    $newKeyword = trim($http->postVariable('TagEditKeyword', ''));
    if (empty($newKeyword)) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Name cannot be empty.');
    }
    if (empty($error) && eZTagsObject::exists($tag->attribute('id'), $newKeyword, $tag->attribute('parent_id'))) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Tag/synonym with that translation already exists in selected location.');
    }
    if (empty($error)) {
        $db = eZDB::instance();
        $db->begin();
        $tagTranslation->setAttribute('keyword', $newKeyword);
        $tagTranslation->setAttribute('status', eZTagsKeyword::STATUS_PUBLISHED);
        $tagTranslation->store();
        if ($http->hasPostVariable('SetAsMainTranslation')) {
            $tag->updateMainTranslation($language->attribute('locale'));
        }
        $tag->setAlwaysAvailable($http->hasPostVariable('AlwaysAvailable'));
        $tag->store();
        $tag->registerSearchObjects();
        $db->commit();
        /* Extended Hook */
        if (class_exists('ezpEvent', false)) {
            $tagParent = $tag->getParent(true);
            ezpEvent::getInstance()->filter('tag/edit', array('tag' => $tag, 'oldParentTag' => $tagParent, 'newParentTag' => $tagParent, 'move' => false));
        }
        return $Module->redirectToView('id', array($tag->attribute('id')));