getPrintName() public method

public getPrintName ( ) : string
return string
Beispiel #1
0
 /**
  * Returns an array of fields from all article types that match
  * the given conditions.
  *
  * @param $p_name
  *         if specified returns fields with the given name
  * @param $p_articleType
  *         if specified returns fields of the given article type
  * @param $p_dataType
  *         if specified returns the fields having the given data type
  *
  * @return array
  */
 public static function FetchFields($p_name = null, $p_articleType = null, $p_dataType = null, $p_negateName = false, $p_negateArticleType = false, $p_negateDataType = false, $p_selectHidden = true, $p_skipCache = false)
 {
     global $g_ado_db;
     if (!$p_skipCache && CampCache::IsEnabled()) {
         $paramsArray['name'] = is_null($p_name) ? 'null' : $p_name;
         $paramsArray['article_type'] = is_null($p_articleType) ? 'null' : $p_articleType;
         $paramsArray['data_type'] = is_null($p_dataType) ? 'null' : $p_dataType;
         $paramsArray['negate_name'] = $p_negateName == false ? 'false' : 'true';
         $paramsArray['negate_article_type'] = $p_negateArticleType == false ? 'false' : 'true';
         $paramsArray['negate_data_type'] = $p_negateDataType == false ? 'false' : 'true';
         $paramsArray['select_hidden'] = $p_selectHidden == false ? 'false' : 'true';
         $cacheListObj = new CampCacheList($paramsArray, __METHOD__);
         $articleTypeFieldsList = $cacheListObj->fetchFromCache();
         if ($articleTypeFieldsList !== false && is_array($articleTypeFieldsList)) {
             return $articleTypeFieldsList;
         }
     }
     $whereClauses = array();
     if (isset($p_name)) {
         $operator = $p_negateName ? '<>' : '=';
         $whereClauses[] = "field_name {$operator} " . $g_ado_db->escape($p_name);
     }
     if (isset($p_articleType)) {
         $operator = $p_negateArticleType ? '<>' : '=';
         $whereClauses[] = "type_name {$operator} " . $g_ado_db->escape($p_articleType);
     }
     if (isset($p_dataType)) {
         $operator = $p_negateDataType ? '<>' : '=';
         $whereClauses[] = "field_type {$operator} " . $g_ado_db->escape($p_dataType);
     }
     if (!$p_selectHidden) {
         $whereClauses[] = 'is_hidden = false';
     }
     $where = count($whereClauses) > 0 ? ' WHERE ' . implode(' and ', $whereClauses) : null;
     $query = "SELECT * FROM `ArticleTypeMetadata` {$where} ORDER BY type_name ASC, field_weight ASC";
     $rows = $g_ado_db->GetAll($query);
     $fields = array();
     foreach ($rows as $row) {
         $field = new ArticleTypeField($row['type_name'], $row['field_name']);
         if ($field->getPrintName() == '') {
             $field->delete();
             continue;
         }
         $fields[] = $field;
     }
     if (!$p_skipCache && CampCache::IsEnabled()) {
         $cacheListObj->storeInCache($fields);
     }
     return $fields;
 }
Beispiel #2
0
    protected function getCustomProperty($p_property)
    {
        $property = $this->translateProperty($p_property);
        if (isset($this->m_customProperties[$property])
        && is_array($this->m_customProperties[$property])) {
            try {
                $dbProperty = $this->m_customProperties[$property][0];
                $fieldValue = $this->m_articleData->getProperty('F'.$dbProperty);

                $articleFieldType = new ArticleTypeField($this->type_name, $dbProperty);
                if ($articleFieldType->getType() == ArticleTypeField::TYPE_BODY) {
                    if (is_null($this->getContentCache($property))) {
                    	$context = CampTemplate::singleton()->context();
                    	$subtitleId = $this->subtitle_url_id($property);
                        $subtitleNo = $context->default_url->get_parameter($subtitleId);
                        if (is_null($subtitleNo)) {
                            $subtitleNo = 0;
                        } elseif ($subtitleNo === 'all') {
                            $subtitleNo = null;
                        }
                        $bodyField = new MetaArticleBodyField($fieldValue, $this,
                                         $articleFieldType->getPrintName(), $this->name, $subtitleNo,
                                         '<span class="subtitle"><p>', '</p></span>');
                        $this->setContentCache($property, $bodyField);
                    }
                    $fieldValue = $this->getContentCache($property);
                }
                if ($articleFieldType->getType() == ArticleTypeField::TYPE_TOPIC) {
                    $fieldValue = new MetaTopic($fieldValue);
                }
                return $fieldValue;
            } catch (InvalidPropertyException $e) {
                // do nothing; will throw another exception with original property field name
            }
            throw new InvalidPropertyException(get_class($this->m_dbObject), $p_property);
        }
        return parent::getCustomProperty($p_property);
    }
Beispiel #3
0
function camp_set_author(ArticleTypeField $p_sourceField, &$p_errors)
{
    $p_errors = array();
    $articles = Article::GetArticlesOfType($p_sourceField->getArticleType());
    foreach ($articles as $article) {
        $articleData = $article->getArticleData();
        $authorName = trim($articleData->getFieldValue($p_sourceField->getPrintName()));
        if (empty($authorName)) {
            continue;
        }
        $author = new Author($authorName);
        if (!$author->exists()) {
            if (!$author->create()) {
                $p_errors[] = getGS('Unable to create author "$1" for article no. $2 ("$3") of type $4.', $author->getName(), $article->getArticleNumber(), $article->getName(), $article->getType());
                continue;
            }
        }
        if (!$article->setAuthorId($author->getId())) {
            $p_errors[] = getGS('Error setting the author "$1" for article no. $2 ("$3") of type $4.', $author->getName(), $article->getArticleNumber(), $article->getName(), $article->getType());
            continue;
        }
    }
    return count($p_errors);
}
function camp_set_author(ArticleTypeField $p_sourceField, &$p_errors)
{
    $translator = \Zend_Registry::get('container')->getService('translator');
    $p_errors = array();
    $articles = Article::GetArticlesOfType($p_sourceField->getArticleType());
    foreach ($articles as $article) {
        $articleData = $article->getArticleData();
        $authorName = trim($articleData->getFieldValue($p_sourceField->getPrintName()));
        if (empty($authorName)) {
            continue;
        }
        $author = new Author($authorName);
        if (!$author->exists()) {
            if (!$author->create()) {
                $p_errors[] = $translator->trans('Unable to create author $1 for article no. $2 ($3) of type $4.', array('$1' => $author->getName(), '$2' => $article->getArticleNumber(), '$3' => $article->getName(), '$4' => $article->getType()), 'home');
                continue;
            }
        }
        if (!$article->setAuthorId($author->getId())) {
            $p_errors[] = $translator->trans('Error setting the author $1 for article no. $2 ($3) of type $4.', array('$1' => $author->getName(), '$2' => $article->getArticleNumber(), '$3' => $article->getName(), '$4' => $article->getType()), 'home');
            continue;
        }
    }
    $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
    $cacheService->clearNamespace('authors');
    $cacheService->clearNamespace('article');
    return count($p_errors);
}
 /**
  * Returns an array of fields from all article types that match
  * the given conditions.
  *
  * @param $p_name
  *         if specified returns fields with the given name
  * @param $p_articleType
  *         if specified returns fields of the given article type
  * @param $p_dataType
  *         if specified returns the fields having the given data type
  *
  * @return array
  */
 public static function FetchFields($p_name = null, $p_articleType = null, $p_dataType = null, $p_negateName = false, $p_negateArticleType = false, $p_negateDataType = false, $p_selectHidden = true, $p_skipCache = false)
 {
     global $g_ado_db;
     $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
     if (!$p_skipCache) {
         $paramsArray['name'] = is_null($p_name) ? 'null' : $p_name;
         $paramsArray['article_type'] = is_null($p_articleType) ? 'null' : $p_articleType;
         $paramsArray['data_type'] = is_null($p_dataType) ? 'null' : $p_dataType;
         $paramsArray['negate_name'] = $p_negateName == false ? 'false' : 'true';
         $paramsArray['negate_article_type'] = $p_negateArticleType == false ? 'false' : 'true';
         $paramsArray['negate_data_type'] = $p_negateDataType == false ? 'false' : 'true';
         $paramsArray['select_hidden'] = $p_selectHidden == false ? 'false' : 'true';
         $paramsArray['method'] = __METHOD__;
         $cacheKey = $cacheService->getCacheKey($paramsArray, 'article_type');
         if ($cacheService->contains($cacheKey)) {
             $articleTypeFieldsList = $cacheService->fetch($cacheKey);
             if ($articleTypeFieldsList !== false && is_array($articleTypeFieldsList)) {
                 return $articleTypeFieldsList;
             }
         }
     }
     $whereClauses = array();
     if (isset($p_name)) {
         $operator = $p_negateName ? '<>' : '=';
         $whereClauses[] = "field_name {$operator} " . $g_ado_db->escape($p_name);
     }
     if (isset($p_articleType)) {
         $operator = $p_negateArticleType ? '<>' : '=';
         $whereClauses[] = "type_name {$operator} " . $g_ado_db->escape($p_articleType);
     }
     if (isset($p_dataType)) {
         $operator = $p_negateDataType ? '<>' : '=';
         $whereClauses[] = "field_type {$operator} " . $g_ado_db->escape($p_dataType);
     }
     if (!$p_selectHidden) {
         $whereClauses[] = 'is_hidden = false';
     }
     $where = count($whereClauses) > 0 ? ' WHERE ' . implode(' and ', $whereClauses) : null;
     $query = "SELECT * FROM `ArticleTypeMetadata` {$where} ORDER BY type_name ASC, field_weight ASC";
     $rows = $g_ado_db->GetAll($query);
     $fields = array();
     foreach ($rows as $row) {
         $field = new ArticleTypeField($row['type_name'], $row['field_name']);
         if ($field->getPrintName() == '') {
             $field->delete();
             continue;
         }
         $fields[] = $field;
     }
     if (!$p_skipCache) {
         $cacheService->save($cacheKey, $fields);
     }
     return $fields;
 }