예제 #1
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;
 }