ArticleTypeField::isContent PHP Method

isContent() public method

Returns true if the current field is a content field.
public isContent ( ) : boolean
return boolean
    public function isContent()
    {
        return $this->m_data['is_content_field'];
    }

Usage Example

Ejemplo n.º 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()) {
         $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
         $cacheKeyObjectType = $cacheService->getCacheKey(array('ObjectType', 'article'), 'ObjectType');
         if ($cacheService->contains($cacheKeyObjectType)) {
             $objectType = $cacheService->fetch($cacheKeyObjectType);
         } else {
             $objectType = new ObjectType('article');
             $cacheService->save($cacheKeyObjectType, $objectType);
         }
         $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();
             $preferencesService = \Zend_Registry::get('container')->getService('system_preferences_service');
             if ($preferencesService->CollectStatistics == 'Y' && !$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;
 }