コード例 #1
0
 /**
  * Generates tag hierarchy string for given tag ID
  *
  * @static
  *
  * @param int $tagID
  *
  * @return string
  */
 public static function generateParentString($tagID)
 {
     $tag = eZTagsObject::fetchWithMainTranslation($tagID);
     if (!$tag instanceof eZTagsObject) {
         return '(' . ezpI18n::tr('extension/eztags/tags/edit', 'no parent') . ')';
     }
     return $tag->getParentString();
 }
コード例 #2
0
ファイル: eztagstype.php プロジェクト: oki34/eztags
 /**
  * Validates class attribute HTTP input
  *
  * @param eZHTTPTool $http
  * @param string $base
  * @param eZContentClassAttribute $attribute
  *
  * @return bool
  */
 public function validateClassAttributeHTTPInput($http, $base, $attribute)
 {
     $classAttributeID = $attribute->attribute('id');
     $maxTags = trim($http->postVariable($base . self::MAX_TAGS_VARIABLE . $classAttributeID, ''));
     if (!is_numeric($maxTags) && !empty($maxTags) || (int) $maxTags < 0) {
         return eZInputValidator::STATE_INVALID;
     }
     $subTreeLimit = (int) $http->postVariable($base . self::SUBTREE_LIMIT_VARIABLE . $classAttributeID, -1);
     if ($subTreeLimit < 0) {
         return eZInputValidator::STATE_INVALID;
     }
     if ($subTreeLimit > 0) {
         $tag = eZTagsObject::fetchWithMainTranslation($subTreeLimit);
         if (!$tag instanceof eZTagsObject || $tag->attribute('main_tag_id') > 0) {
             return eZInputValidator::STATE_INVALID;
         }
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
コード例 #3
0
ファイル: ezjsctags.php プロジェクト: BornaP/eztags
 /**
  * Returns requested tag translations
  *
  * @static
  *
  * @param array $args
  *
  * @return array
  */
 public static function tagtranslations($args)
 {
     $returnArray = array('status' => 'success', 'message' => '', 'translations' => false);
     $http = eZHTTPTool::instance();
     $tagID = (int) $http->postVariable('tag_id', 0);
     $tag = eZTagsObject::fetchWithMainTranslation($tagID);
     if (!$tag instanceof eZTagsObject) {
         return $returnArray;
     }
     $returnArray['translations'] = array();
     /** @var eZTagsKeyword[] $tagTranslations */
     $tagTranslations = $tag->getTranslations();
     if (!is_array($tagTranslations) || empty($tagTranslations)) {
         return $returnArray;
     }
     foreach ($tagTranslations as $translation) {
         $returnArray['translations'][] = array('locale' => $translation->attribute('locale'), 'translation' => $translation->attribute('keyword'));
     }
     return $returnArray;
 }
コード例 #4
0
ファイル: merge.php プロジェクト: oki34/eztags
if ($http->hasPostVariable('DiscardButton')) {
    return $Module->redirectToView('id', array($tag->attribute('id')));
}
if ($tag->attribute('main_tag_id') != 0) {
    return $Module->redirectToView('merge', array($tag->attribute('main_tag_id')));
}
if ($tag->getSubTreeLimitationsCount() > 0) {
    $mergeAllowed = false;
    $error = ezpI18n::tr('extension/eztags/errors', 'Tag cannot be modified because it is being used as subtree limitation in one or more class attributes.');
}
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') && $mergeAllowed) {
    $mainTagID = (int) $http->postVariable('MainTagID', 0);
    $mainTag = eZTagsObject::fetchWithMainTranslation($mainTagID);
    if (!$mainTag instanceof eZTagsObject) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Selected target tag is invalid.');
    }
    if (empty($error)) {
        $db = eZDB::instance();
        $db->begin();
        $oldParentTag = false;
        if ($tag->attribute('parent_id') != $mainTag->attribute('parent_id')) {
            $oldParentTag = $tag->getParent(true);
            if ($oldParentTag instanceof eZTagsObject) {
                $oldParentTag->updateModified();
            }
        }
        /* Extended Hook */
        if (class_exists('ezpEvent', false)) {
コード例 #5
0
ファイル: add.php プロジェクト: oki34/eztags
<?php

/** @var eZModule $Module */
/** @var array $Params */
$http = eZHTTPTool::instance();
$parentTagID = (int) $http->postVariable('TagEditParentID', $Params['ParentTagID']);
if ($parentTagID < 0) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
$locale = (string) $Params['Locale'];
if (empty($locale)) {
    $locale = $http->postVariable('Locale', false);
}
$parentTag = false;
if ($parentTagID > 0) {
    $parentTag = eZTagsObject::fetchWithMainTranslation($parentTagID);
    if (!$parentTag instanceof eZTagsObject) {
        return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
    }
    if ($parentTag->attribute('main_tag_id') != 0) {
        return $Module->redirectToView('add', array($parentTag->attribute('main_tag_id')));
    }
}
if ($http->hasPostVariable('DiscardButton')) {
    if ($parentTag instanceof eZTagsObject) {
        return $Module->redirectToView('id', array($parentTag->attribute('id')));
    }
    return $Module->redirectToView('dashboard', array());
}
$userLimitations = eZTagsTemplateFunctions::getSimplifiedUserAccess('tags', 'add');
$hasAccess = false;
コード例 #6
0
ファイル: eztags.php プロジェクト: oki34/eztags
 /**
  * Returns the array with permission info for linking tags to current content object attribute
  *
  * @return array
  */
 private function getPermissionArray()
 {
     $permissionArray = array('can_add' => false, 'subtree_limit' => $this->Attribute->contentClassAttribute()->attribute(eZTagsType::SUBTREE_LIMIT_FIELD), 'allowed_locations' => array(), 'allowed_locations_tags' => false);
     $userLimitations = eZTagsTemplateFunctions::getSimplifiedUserAccess('tags', 'add');
     if ($userLimitations['accessWord'] == 'no') {
         return $permissionArray;
     }
     $userLimitations = isset($userLimitations['simplifiedLimitations']['Tag']) ? $userLimitations['simplifiedLimitations']['Tag'] : array();
     $limitTag = eZTagsObject::fetchWithMainTranslation($permissionArray['subtree_limit']);
     if (empty($userLimitations)) {
         if ($permissionArray['subtree_limit'] == 0 || $limitTag instanceof eZTagsObject) {
             $permissionArray['allowed_locations'] = array($permissionArray['subtree_limit']);
             if ($limitTag instanceof eZTagsObject) {
                 $permissionArray['allowed_locations_tags'] = array($limitTag);
             }
         }
     } else {
         if ($permissionArray['subtree_limit'] == 0) {
             $permissionArray['allowed_locations_tags'] = array();
             /** @var eZTagsObject[] $userLimitations */
             $userLimitations = eZTagsObject::fetchList(array('id' => array($userLimitations)), null, null, true);
             if (is_array($userLimitations) && !empty($userLimitations)) {
                 foreach ($userLimitations as $limitation) {
                     $permissionArray['allowed_locations'][] = $limitation->attribute('id');
                     $permissionArray['allowed_locations_tags'][] = $limitation;
                 }
             }
         } else {
             if ($limitTag instanceof eZTagsObject) {
                 /** @var eZTagsObject[] $userLimitations */
                 $userLimitations = eZTagsObject::fetchList(array('id' => array($userLimitations)), null, null, true);
                 if (is_array($userLimitations) && !empty($userLimitations)) {
                     $pathString = $limitTag->attribute('path_string');
                     foreach ($userLimitations as $limitation) {
                         if (strpos($pathString, '/' . $limitation->attribute('id') . '/') !== false) {
                             $permissionArray['allowed_locations'] = array($permissionArray['subtree_limit']);
                             $permissionArray['allowed_locations_tags'] = array($limitTag);
                             break;
                         }
                     }
                 }
             }
         }
     }
     if (!empty($permissionArray['allowed_locations'])) {
         $permissionArray['can_add'] = true;
     }
     return $permissionArray;
 }
コード例 #7
0
ファイル: edit.php プロジェクト: oki34/eztags
}
$warning = '';
$error = '';
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')) {
    $newKeyword = trim($http->postVariable('TagEditKeyword', ''));
    if (empty($newKeyword)) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Name cannot be empty.');
    }
    $newParentID = 0;
    $newParentTag = false;
    if (empty($error)) {
        $newParentID = (int) $http->postVariable('TagEditParentID', 0);
        $newParentTag = eZTagsObject::fetchWithMainTranslation($newParentID);
        if (!$newParentTag instanceof eZTagsObject && $newParentID > 0) {
            $error = ezpI18n::tr('extension/eztags/errors', 'Selected target tag is invalid.');
        }
    }
    if (empty($error) && eZTagsObject::exists($tag->attribute('id'), $newKeyword, $newParentID)) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Tag/synonym with that translation 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) {