コード例 #1
0
 function node()
 {
     if ($this->Tag == null) {
         $this->Tag = eZTagsObject::fetch($this->attribute('tag_id'));
     }
     return $this->Tag;
 }
コード例 #2
0
 function findTags($id)
 {
     if (is_numeric($id)) {
         $tags = array(eZTagsObject::fetch($id));
     } else {
         $tags = eZTagsObject::fetchByKeyword($id);
     }
     return $tags;
 }
コード例 #3
0
 /**
  * Fetches eZTagsObject object for the provided tag ID
  *
  * @static
  * @param integer $tag_id
  * @return array
  */
 public static function fetchTag($tag_id)
 {
     $result = eZTagsObject::fetch($tag_id);
     if ($result instanceof eZTagsObject) {
         return array('result' => $result);
     } else {
         return array('result' => false);
     }
 }
コード例 #4
0
 /**
  * Ritorna l'elengo dei tag disponibili
  * 
  * @return eZTagsObject[]
  */
 public static function notificationAvailableTags()
 {
     $class = eZContentClass::fetchByIdentifier(self::CLASS_IDENTIFIER);
     if ($class instanceof eZContentClass) {
         $classAttribute = $class->fetchAttributeByIdentifier(self::TAG_ATTRIBUTE_IDENTIFIER);
         if ($classAttribute instanceof eZContentClassAttribute) {
             $tagRoot = eZTagsObject::fetch(intval($classAttribute->attribute(eZTagsType::SUBTREE_LIMIT_FIELD)));
             return $tagRoot->getChildren();
         }
     }
     return array();
 }
コード例 #5
0
 /**
  * Generates tag heirarchy string for given tag ID
  *
  * @static
  * @param integer $tagID
  * @return string
  */
 static function generateParentString($tagID)
 {
     $tag = eZTagsObject::fetch($tagID);
     if (!$tag instanceof eZTagsObject) {
         return '(' . ezpI18n::tr('extension/eztags/tags/edit', 'no parent') . ')';
     }
     $synonymsCount = $tag->getSynonymsCount();
     $keywordsArray = array();
     while ($tag->hasParent()) {
         $keywordsArray[] = $synonymsCount > 0 ? $tag->attribute('keyword') . ' (+' . $synonymsCount . ')' : $tag->attribute('keyword');
         $tag = $tag->getParent();
         $synonymsCount = $tag->getSynonymsCount();
     }
     $keywordsArray[] = $synonymsCount > 0 ? $tag->attribute('keyword') . ' (+' . $synonymsCount . ')' : $tag->attribute('keyword');
     return implode(' / ', array_reverse($keywordsArray));
 }
コード例 #6
0
 /**
  * Fetches eZTagsObject object for the provided tag ID
  *
  * @static
  *
  * @param int $tagID
  * @param mixed $language
  *
  * @return array
  */
 public static function fetchTag($tagID, $language = false)
 {
     if ($language) {
         if (!is_array($language)) {
             $language = array($language);
         }
         eZContentLanguage::setPrioritizedLanguages($language);
     }
     $result = false;
     if (is_numeric($tagID)) {
         $result = eZTagsObject::fetch($tagID);
     } else {
         if (is_array($tagID) && !empty($tagID)) {
             $result = eZTagsObject::fetchList(array('id' => array($tagID)));
         }
     }
     if ($language) {
         eZContentLanguage::clearPrioritizedLanguages();
     }
     if ($result instanceof eZTagsObject || is_array($result) && !empty($result)) {
         return array('result' => $result);
     }
     return array('result' => false);
 }
コード例 #7
0
}
for ($i = 0, $obLevel = ob_get_level(); $i < $obLevel; ++$i) {
    ob_end_clean();
}
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + MAX_AGE) . ' GMT');
    header('Cache-Control: max-age=' . MAX_AGE);
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) . ' GMT');
    header('Pragma: ');
    eZExecution::cleanExit();
}
$tagID = (int) $Params['TagID'];
$siteINI = eZINI::instance();
$eztagsINI = eZINI::instance('eztags.ini');
$tag = eZTagsObject::fetch($tagID);
if (!($tag instanceof eZTagsObject || $TagID == 0)) {
    header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
} else {
    $children = eZTagsObject::fetchByParentID($tagID);
    $response = array();
    $response['error_code'] = 0;
    $response['id'] = $tagID;
    $response['parent_id'] = $tag instanceof eZTagsObject ? (int) $tag->attribute('parent_id') : -1;
    $response['children_count'] = count($children);
    $response['children'] = array();
    foreach ($children as $child) {
        $childResponse = array();
        $childResponse['id'] = (int) $child->attribute('id');
        $childResponse['parent_id'] = (int) $child->attribute('parent_id');
        $childResponse['has_children'] = eZTagsObject::childrenCountByParentID($child->attribute('id')) ? 1 : 0;
コード例 #8
0
ファイル: eztagstype.php プロジェクト: netbliss/eztags
 /**
  * Validates class attribute HTTP input
  *
  * @param eZHTTPTool $http
  * @param string $base
  * @param eZContentClassAttribute $attribute
  * @return bool
  */
 function validateClassAttributeHTTPInput($http, $base, $attribute)
 {
     $maxTagsName = $base . self::MAX_TAGS_VARIABLE . $attribute->attribute('id');
     if (!$http->hasPostVariable($maxTagsName) || !is_numeric($http->postVariable($maxTagsName)) && trim($http->postVariable($maxTagsName)) != '') {
         return eZInputValidator::STATE_INVALID;
     }
     $subTreeLimitName = $base . self::SUBTREE_LIMIT_VARIABLE . $attribute->attribute('id');
     if (!$http->hasPostVariable($subTreeLimitName) || (int) $http->postVariable($subTreeLimitName) < 0) {
         return eZInputValidator::STATE_INVALID;
     }
     $subTreeLimit = (int) $http->postVariable($subTreeLimitName);
     $tag = eZTagsObject::fetch($subTreeLimit);
     if (!$tag instanceof eZTagsObject && $subTreeLimit > 0) {
         return eZInputValidator::STATE_INVALID;
     }
     if ($subTreeLimit > 0 && $tag->attribute('main_tag_id') > 0) {
         return eZInputValidator::STATE_INVALID;
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
コード例 #9
0
ファイル: edit.php プロジェクト: netbliss/eztags
    return $Module->redirectToView('edit', array($tag->attribute('main_tag_id')));
}
if ($http->hasPostVariable('DiscardButton')) {
    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;
        }
コード例 #10
0
ファイル: addsynonym.php プロジェクト: netbliss/eztags
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')));
    }
}
$tpl = eZTemplate::factory();
$tpl->setVariable('main_tag', $mainTag);
$tpl->setVariable('error', $error);
$tpl->setVariable('ui_context', 'edit');
コード例 #11
0
ファイル: makesynonym.php プロジェクト: netbliss/eztags
if ($tag->getSubTreeLimitationsCount() > 0) {
    $convertAllowed = 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.');
} else {
    if ($http->hasPostVariable('DiscardButton')) {
        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;
コード例 #12
0
ファイル: eztags.php プロジェクト: jordanmanning/ezpublish
 /**
  * Returns all allowed locations user has access to
  *
  * @static
  * @param int $attributeSubTreeLimit
  * @param array $userLimitations
  * @return bool
  */
 private static function getAllowedLocations($attributeSubTreeLimit, $userLimitations)
 {
     if (empty($userLimitations)) {
         return array((string) $attributeSubTreeLimit);
     } else {
         if ($attributeSubTreeLimit == 0) {
             return $userLimitations;
         } else {
             $limitTag = eZTagsObject::fetch($attributeSubTreeLimit);
             $pathString = $limitTag instanceof eZTagsObject ? $limitTag->attribute('path_string') : '/';
             foreach ($userLimitations as $l) {
                 if (strpos($pathString, '/' . $l . '/') !== false) {
                     return array((string) $attributeSubTreeLimit);
                 }
             }
         }
     }
     return array();
 }
コード例 #13
0
ファイル: tag.php プロジェクト: sushilbshinde/ezpublish-study
    public static function fetchByPathName($path)
    {
        if (!is_array($path) && is_string($path))
            $path = array($path);

        if (count($path) == 0)
            return false;

        $db         = eZDB::instance();
        $definition = eZTagsObject::definition();
        $table      = $definition['name'];
        $from       = array();
        $where      = array();
        $lastIndex  = 0;

        reset($path);

        while(list($index, $keyword) = each($path))
        {
            if ($index == 0)
            {
                $from[]     = sprintf('%1$s as t%2$d', $table, $index);
                $where[]    = sprintf('t%1$d.keyword like "%2$s" AND t%1$d.depth = 1', $index, $db->escapeString($keyword));
            }
            else
            {
                $from[]     = sprintf('INNER JOIN %1$s as t%3$d ON t%2$d.id = t%3$d.parent_id', $table, $index - 1, $index);
                $where[]    = sprintf('t%d.keyword like "%s"', $index, $db->escapeString($keyword));
            }

            $lastIndex = $index;
        }

        $query = sprintf(
            'SELECT t%d.id From %s Where %s;',
            $lastIndex,
            implode(' ', $from),
            implode(' AND ', $where)
        );

        $result = $db->arrayQuery($query);

        if (is_array($result) && count($result))
            return eZTagsObject::fetch($result[0]['id']);

        return false;
    }
コード例 #14
0
ファイル: id.php プロジェクト: oki34/eztags
<?php

/** @var eZModule $Module */
/** @var array $Params */
$tagID = (int) $Params['TagID'];
$locale = (string) $Params['Locale'];
$locale = !empty($locale) ? $locale : false;
$http = eZHTTPTool::instance();
$tag = eZTagsObject::fetch($tagID, $locale);
if (!$tag instanceof eZTagsObject) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
$viewParameters = array();
if (isset($Params['Offset'])) {
    $viewParameters['offset'] = (int) $Params['Offset'];
}
if (isset($Params['Tab'])) {
    $viewParameters['tab'] = trim($Params['Tab']);
}
$tpl = eZTemplate::factory();
$tpl->setVariable('tag', $tag);
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('show_reindex_message', false);
if ($http->hasSessionVariable('eZTagsShowReindexMessage')) {
    $http->removeSessionVariable('eZTagsShowReindexMessage');
    $tpl->setVariable('show_reindex_message', true);
}
$Result = array();
$Result['content'] = $tpl->fetch('design:tags/view.tpl');
$Result['path'] = eZTagsObject::generateModuleResultPath($tag, false);
コード例 #15
0
 /**
  * Fetches subtree tag count by specified parameters
  *
  * @static
  * @param array $params
  * @param integer $tagID
  * @return integer
  */
 static function subTreeCountByTagID($params = array(), $tagID = 0)
 {
     if (!is_numeric($tagID) || (int) $tagID < 0) {
         return 0;
     }
     $tag = eZTagsObject::fetch((int) $tagID);
     if ((int) $tagID > 0 && !$tag instanceof eZTagsObject && $tag->attribute('main_tag_id') != 0) {
         return 0;
     }
     if (!is_array($params)) {
         $params = array();
     }
     $depth = isset($params['Depth']) ? $params['Depth'] : false;
     $depthOperator = isset($params['DepthOperator']) ? $params['DepthOperator'] : false;
     $includeSynonyms = isset($params['IncludeSynonyms']) ? (bool) $params['IncludeSynonyms'] : false;
     $fetchParams = array();
     if ((int) $tagID > 0) {
         $fetchParams['path_string'] = array('like', '%/' . (string) (int) $tagID . '/%');
         $fetchParams['id'] = array('!=', (int) $tagID);
     }
     if (!$includeSynonyms) {
         $fetchParams['main_tag_id'] = 0;
     }
     if ($depth !== false && (int) $depth > 0) {
         $tagDepth = 0;
         if ($tag instanceof eZTagsObject) {
             $tagDepth = (int) $tag->attribute('depth');
         }
         $depth = (int) $depth + $tagDepth;
         $sqlDepthOperator = '<=';
         if ($depthOperator == 'lt') {
             $sqlDepthOperator = '<';
         } else {
             if ($depthOperator == 'gt') {
                 $sqlDepthOperator = '>';
             } else {
                 if ($depthOperator == 'le') {
                     $sqlDepthOperator = '<=';
                 } else {
                     if ($depthOperator == 'ge') {
                         $sqlDepthOperator = '>=';
                     } else {
                         if ($depthOperator == 'eq') {
                             $sqlDepthOperator = '=';
                         }
                     }
                 }
             }
         }
         $fetchParams['depth'] = array($sqlDepthOperator, $depth);
     }
     $count = self::fetchListCount($fetchParams);
     if (is_numeric($count)) {
         return $count;
     }
     return 0;
 }
コード例 #16
0
ファイル: add.php プロジェクト: netbliss/eztags
<?php

$http = eZHTTPTool::instance();
$parentTagID = (int) $Params['ParentTagID'];
if ($http->hasPostVariable('TagEditParentID')) {
    $parentTagID = (int) $http->postVariable('TagEditParentID');
}
$error = '';
$parentTag = false;
if ($parentTagID < 0) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
if ($parentTagID > 0) {
    $parentTag = eZTagsObject::fetch($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')));
    }
}
$userLimitations = eZTagsTemplateFunctions::getSimplifiedUserAccess('tags', 'add');
$hasAccess = false;
if (!isset($userLimitations['simplifiedLimitations']['Tag'])) {
    $hasAccess = true;
} else {
    $parentTagPathString = $parentTag instanceof eZTagsObject ? $parentTag->attribute('path_string') : '/';
    foreach ($userLimitations['simplifiedLimitations']['Tag'] as $key => $value) {
        if (strpos($parentTagPathString, '/' . $value . '/') !== false) {
            $hasAccess = true;
            break;
コード例 #17
0
ファイル: editsynonym.php プロジェクト: oki34/eztags
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
$tag = eZTagsObject::fetchWithMainTranslation($tagID);
if (!$tag instanceof eZTagsObject) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
if ($tag->attribute('main_tag_id') == 0) {
    return $Module->redirectToView('edit', array($tag->attribute('id')));
}
$tagTranslation = eZTagsKeyword::fetch($tag->attribute('id'), $language->attribute('locale'), true);
if (!$tagTranslation instanceof eZTagsKeyword) {
    $tagTranslation = new eZTagsKeyword(array('keyword_id' => $tag->attribute('id'), 'keyword' => '', 'language_id' => $language->attribute('id'), 'locale' => $language->attribute('locale'), 'status' => eZTagsKeyword::STATUS_DRAFT));
    $tagTranslation->store();
    $tag->updateLanguageMask();
}
$tag = eZTagsObject::fetch($tagID, $language->attribute('locale'));
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();