getObjectTypeId() public method

public getObjectTypeId ( ) : integer
return integer
コード例 #1
0
/**
 * Campsite Map function plugin
 *
 * Type:     function
 * Name:     count
 * Purpose:  Triggers a statistics counting request
 *
 * @param array
 *     $p_params List of parameters from template
 * @param object
 *     $p_smarty Smarty template object
 *
 * @return
 *     string The html content
 */
function smarty_function_count($p_params, &$p_smarty)
{
    global $Campsite;
    $campsite = $p_smarty->getTemplateVars('gimme');
    $content = '';
    $art_number = 0;
    $art_language_num = 0;
    $art_language_code = '';
    if (isset($p_params['article']) && is_numeric($p_params['article'])) {
        $art_number = $p_params['article'];
    }
    if (isset($p_params['language'])) {
        $langs = array();
        if (is_numeric($p_params['language'])) {
            $langs = \Language::GetLanguages($p_params['language']);
        } else {
            $langs = \Language::GetLanguages(null, $p_params['language']);
        }
        if (!isset($langs[0])) {
            return '';
            // 'no lang'
        }
        $art_language_obj = $langs[0];
        $art_language_num = $art_language_obj->getLanguageId();
        $art_language_code = $art_language_obj->getCode();
    }
    $count_automatically = true;
    if (isset($p_params['dont_count_automatically'])) {
        $count_automatically = false;
    }
    if (!$art_number || !$art_language_num) {
        $meta_article = $campsite->article;
        if ($meta_article->defined) {
            if (!$art_number) {
                $art_number = $meta_article->number;
            }
            if (!$art_language_num) {
                $art_language_meta = $meta_article->language;
                $art_language_num = $art_language_meta->number;
                $art_language_code = $art_language_meta->code;
            }
        }
    }
    if (!$art_language_num) {
        $art_language_meta = $campsite->language;
        $art_language_num = $art_language_meta->number;
        $art_language_code = $art_language_meta->code;
    }
    if (!$art_number || !$art_language_num) {
        return '';
        // 'no art_num or lang'
    }
    $article = new \Article($art_language_num, $art_number);
    if (!$article->exists()) {
        return '';
        // 'no art'
    }
    try {
        $requestObjectId = $article->getProperty('object_id');
        $updateArticle = empty($requestObjectId);
        $objectType = new \ObjectType('article');
        $object_type_id = $objectType->getObjectTypeId();
        if ($updateArticle) {
            $requestObject = new \RequestObject($requestObjectId);
            if (!$requestObject->exists()) {
                $requestObject->create(array('object_type_id' => $objectType->getObjectTypeId()));
                $requestObjectId = $requestObject->getObjectId();
            }
            $article->setProperty('object_id', $requestObjectId);
        }
        // statistics shall be only gathered if the site admin set it on (and not for editor previews)
        if (!$campsite->preview) {
            $stat_web_url = $Campsite['WEBSITE_URL'];
            if ('/' != $stat_web_url[strlen($stat_web_url) - 1]) {
                $stat_web_url .= '/';
            }
            $article_number = $article->getProperty('Number');
            $name_spec = '_' . $article_number . '_' . $art_language_code;
            $content .= \Statistics::JavaScriptTrigger(array('count_automatically' => $count_automatically, 'name_spec' => $name_spec, 'object_type_id' => $object_type_id, 'request_object_id' => $requestObjectId));
        }
    } catch (\Exception $ex) {
        return '';
    }
    return $content;
}
コード例 #2
0
 /**
  * Returns the content of the given subtitles of the article body field.
  *
  * @param array $p_subtitles
  * @return string
  */
 private function getContent(array $p_subtitles = array())
 {
     global $Campsite;
     $printAll = count($p_subtitles) == 0;
     $content = '';
     foreach ($this->m_subtitles as $index => $subtitle) {
         if (!$printAll && array_search($index, $p_subtitles) === false) {
             continue;
         }
         $content .= $index > 0 ? $subtitle->formatted_name : '';
         $content .= $subtitle->content;
     }
     if ($this->m_articleTypeField->isContent()) {
         $objectType = new ObjectType('article');
         $requestObjectId = $this->m_parent_article->getProperty('object_id');
         $updateArticle = empty($requestObjectId);
         try {
             if ($updateArticle) {
                 $requestObject = new RequestObject($requestObjectId);
                 if (!$requestObject->exists()) {
                     $requestObject->create(array('object_type_id' => $objectType->getObjectTypeId()));
                     $requestObjectId = $requestObject->getObjectId();
                 }
                 $this->m_parent_article->setProperty('object_id', $requestObjectId);
             }
             // statistics shall be only gathered if the site admin set it on (and not for editor previews)
             $context = CampTemplate::singleton()->context();
             if (SystemPref::CollectStatisticsAuto() && !$context->preview) {
                 $stat_web_url = $Campsite['WEBSITE_URL'];
                 if ('/' != $stat_web_url[strlen($stat_web_url) - 1]) {
                     $stat_web_url .= '/';
                 }
                 $article_number = $this->m_parent_article->getProperty('Number');
                 $language_obj = new MetaLanguage($this->m_parent_article->getProperty('IdLanguage'));
                 $language_code = $language_obj->Code;
                 $name_spec = '_' . $article_number . '_' . $language_code;
                 $object_type_id = $objectType->getObjectTypeId();
                 $content .= Statistics::JavaScriptTrigger(array('name_spec' => $name_spec, 'object_type_id' => $object_type_id, 'request_object_id' => $requestObjectId));
             }
         } catch (Exception $ex) {
             $content .= "<p><strong><font color=\"red\">INTERNAL ERROR! " . $ex->getMessage() . "</font></strong></p>\n";
             // do something
         }
     }
     return $content;
 }