示例#1
0
文件: edit.php 项目: netbliss/eztags
    return $Module->redirectToView('id', array($tagID));
}
if ($tag->isInsideSubTreeLimit()) {
    $warning = ezpI18n::tr('extension/eztags/warnings', 'TAKE CARE: Tag is inside class attribute subtree limit(s). If moved outside those limits, it could lead to inconsistency as objects could end up with tags that they are not supposed to have.');
}
if ($http->hasPostVariable('SaveButton')) {
    if (!($http->hasPostVariable('TagEditKeyword') && strlen(trim($http->postVariable('TagEditKeyword'))) > 0)) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Name cannot be empty.');
    }
    if (empty($error) && !($http->hasPostVariable('TagEditParentID') && (int) $http->postVariable('TagEditParentID') >= 0)) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Selected target tag is invalid.');
    }
    $newParentTag = eZTagsObject::fetch((int) $http->postVariable('TagEditParentID'));
    $newParentID = $newParentTag instanceof eZTagsObject ? $newParentTag->attribute('id') : 0;
    $newKeyword = trim($http->postVariable('TagEditKeyword'));
    if (empty($error) && eZTagsObject::exists($tag->attribute('id'), $newKeyword, $newParentID)) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Tag/synonym with that name already exists in selected location.');
    }
    if (empty($error)) {
        $updateDepth = false;
        $updatePathString = false;
        $db = eZDB::instance();
        $db->begin();
        $oldParentDepth = $tag->attribute('depth') - 1;
        $newParentDepth = $newParentTag instanceof eZTagsObject ? $newParentTag->attribute('depth') : 0;
        if ($oldParentDepth != $newParentDepth) {
            $updateDepth = true;
        }
        if ($tag->attribute('parent_id') != $newParentID) {
            $oldParentTag = $tag->getParent();
            if ($oldParentTag instanceof eZTagsObject) {
示例#2
0
$mainTag = eZTagsObject::fetch($mainTagID);
if (!$mainTag instanceof eZTagsObject) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
if ($mainTag->attribute('main_tag_id') != 0) {
    return $Module->redirectToView('addsynonym', array($mainTag->attribute('main_tag_id')));
}
if ($http->hasPostVariable('DiscardButton')) {
    return $Module->redirectToView('id', array($mainTagID));
}
if ($http->hasPostVariable('SaveButton')) {
    if (!($http->hasPostVariable('TagEditKeyword') && strlen(trim($http->postVariable('TagEditKeyword'))) > 0)) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Name cannot be empty.');
    }
    $newKeyword = trim($http->postVariable('TagEditKeyword'));
    if (empty($error) && eZTagsObject::exists(0, $newKeyword, $mainTag->attribute('parent_id'))) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Tag/synonym with that name already exists in selected location.');
    }
    if (empty($error)) {
        $parentTag = eZTagsObject::fetch($mainTag->attribute('parent_id'));
        $db = eZDB::instance();
        $db->begin();
        $tag = new eZTagsObject(array('parent_id' => $mainTag->attribute('parent_id'), 'main_tag_id' => $mainTagID, 'keyword' => $newKeyword, 'depth' => $mainTag->attribute('depth'), 'path_string' => $parentTag instanceof eZTagsObject ? $parentTag->attribute('path_string') : '/'));
        $tag->store();
        $tag->setAttribute('path_string', $tag->attribute('path_string') . $tag->attribute('id') . '/');
        $tag->store();
        $tag->updateModified();
        $db->commit();
        return $Module->redirectToView('id', array($tag->attribute('id')));
    }
}
示例#3
0
文件: add.php 项目: oki34/eztags
    $Result['ui_context'] = 'edit';
    $Result['path'] = eZTagsObject::generateModuleResultPath($parentTag, null, ezpI18n::tr('extension/eztags/tags/edit', 'New tag'));
    return;
}
/** @var eZContentLanguage $language */
$language = eZContentLanguage::fetchByLocale($locale);
if (!$language instanceof eZContentLanguage) {
    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(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();
示例#4
0
     return $Module->redirectToView('id', array($tagID));
 }
 if ($tag->isInsideSubTreeLimit()) {
     $warning = ezpI18n::tr('extension/eztags/warnings', 'TAKE CARE: Tag is inside class attribute subtree limit(s). If moved outside those limits, it could lead to inconsistency as objects could end up with tags that they are not supposed to have.');
 }
 if ($http->hasPostVariable('SaveButton')) {
     if (!($http->hasPostVariable('MainTagID') && (int) $http->postVariable('MainTagID') > 0)) {
         $error = ezpI18n::tr('extension/eztags/errors', 'Selected target tag is invalid.');
     }
     if (empty($error)) {
         $mainTag = eZTagsObject::fetch((int) $http->postVariable('MainTagID'));
         if (!$mainTag instanceof eZTagsObject) {
             $error = ezpI18n::tr('extension/eztags/errors', 'Selected target tag is invalid.');
         }
     }
     if (empty($error) && eZTagsObject::exists($tag->attribute('id'), $tag->attribute('keyword'), $mainTag->attribute('parent_id'))) {
         $error = ezpI18n::tr('extension/eztags/errors', 'Tag/synonym with that name already exists in selected location.');
     }
     if (empty($error)) {
         $updateDepth = false;
         $updatePathString = false;
         $newParentTag = $mainTag->getParent();
         $db = eZDB::instance();
         $db->begin();
         if ($tag->attribute('depth') != $mainTag->attribute('depth')) {
             $updateDepth = true;
         }
         if ($tag->attribute('parent_id') != $mainTag->attribute('parent_id')) {
             $oldParentTag = $tag->getParent();
             if ($oldParentTag instanceof eZTagsObject) {
                 $oldParentTag->updateModified();
示例#5
0
文件: movetags.php 项目: oki34/eztags
 $db = eZDB::instance();
 $unmovableTags = array();
 foreach ($tagsList as $tag) {
     if ($tag->attribute('main_tag_id') != 0) {
         continue;
     }
     if ((int) $tag->attribute('parent_id') === $newParentID) {
         continue;
     }
     // @todo: check for subtree limits
     $tagKeywords = array_map(function ($translation) {
         /** @var eZTagsKeyword $translation */
         return $translation->attribute('keyword');
     }, $tag->getTranslations());
     foreach ($tagKeywords as $tagKeyword) {
         if (eZTagsObject::exists($tag->attribute('id'), $tagKeyword, $newParentID)) {
             $unmovableTags[] = $tag;
             continue 2;
         }
     }
     $db->begin();
     $updateDepth = false;
     $oldParentDepth = $tag->attribute('depth') - 1;
     $newParentDepth = $newParentTag instanceof eZTagsObject ? $newParentTag->attribute('depth') : 0;
     if ($oldParentDepth != $newParentDepth) {
         $updateDepth = true;
     }
     $oldParentTag = $tag->getParent(true);
     if ($oldParentTag instanceof eZTagsObject) {
         $oldParentTag->updateModified();
     }