FetchFields() public static method

Returns an array of fields from all article types that match the given conditions.
public static 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 ) : array
$p_name if specified returns fields with the given name
$p_articleType if specified returns fields of the given article type
$p_dataType if specified returns the fields having the given data type
return array
コード例 #1
0
ファイル: Article.php プロジェクト: nistormihai/Newscoop
    private static function ProcessCustomField(array $p_comparisonOperation, $p_languageId = null)
    {
        global $g_ado_db;

        $fieldName = $p_comparisonOperation['left'];
        $fieldParts = preg_split('/\./', $fieldName);
        if (count($fieldParts) > 1) {
            $fieldName = $fieldParts[1];
            $articleType = $fieldParts[0];
            $field = new ArticleTypeField($articleType, $fieldName);
            if (!$field->exists()) {
                return null;
            }
            $fields = array($field);
        } else {
            $articleType = null;
            $fields = ArticleTypeField::FetchFields($fieldName, $articleType,
            null, false, false, false, true, true);
            if (count($fields) == 0) {
                return null;
            }
        }
        $queries = array();
        foreach ($fields as $fieldObj) {
            $query .= '        SELECT NrArticle FROM `X' . $fieldObj->getArticleType()
                   . '` WHERE ' . $fieldObj->getName() . ' '
                   . $p_comparisonOperation['symbol']
                   . " '" . $g_ado_db->escape($p_comparisonOperation['right']) . "'";
            if (!is_null($p_languageId)) {
                $query .= " AND IdLanguage = '" . $g_ado_db->escape($p_languageId) . "'";
            }
            $query .= "\n";
            $queries[] = $query;
        }
        if (count($queries) == 0) {
            return null;
        }
        return implode("        union\n", $queries);
    }
コード例 #2
0
ファイル: set-author.php プロジェクト: nistormihai/Newscoop
		camp_set_author($field, $errors);
		if (count($errors) == 0) {
			camp_html_add_msg(getGS("The author was set successfuly for articles of type '$1' from the field '$2'.",
			                        $field->getArticleType(), $field->getPrintName()), 'ok');
		} else {
            camp_html_add_msg(getGS("There were errors setting the author for articles of type '$1' from the field '$2'.",
                                    $field->getArticleType(), $field->getPrintName()));
		}
        foreach ($errors as $error) {
            camp_html_add_msg($error);
        }
	}
    camp_html_display_msgs();
}

$availableFields = ArticleTypeField::FetchFields(null, null, 'text', false, false, false, true, true);

?>

<br/>
<form name="f_set_author" method="post">
<TABLE BORDER="0" CELLSPACING="4" CELLPADDING="2" CLASS="table_input">
<TR>
    <TD VALIGN="TOP" align="left" nowrap>
        <?php putGS("Select the field from which to generate the author"); ?>:
    </td>
    <td valign="top" align="left">
        <select name="f_src_author_field">
        <?php
        foreach ($availableFields as $field) {
        	echo "<option value=\"" . htmlspecialchars($field->getPrintName())
コード例 #3
0
ファイル: ArticlesList.php プロジェクト: nistormihai/Newscoop
	private static function ReadDynamicFields()
	{
		if (is_null(self::$s_dynamicFields)) {
            require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleTypeField.php');
			self::$s_dynamicFields = ArticleTypeField::FetchFields();
		}
	}
コード例 #4
0
ファイル: Article.php プロジェクト: alvsgithub/Newscoop
 /**
  * Processes an order directive on custom data fields.
  *
  * @param string $p_fieldName
  * @param string $p_defaultValue
  *
  * @return string
  *                The string containing processed values of the condition
  */
 private static function GetCustomOrder($p_fieldType, $p_articleType, $p_fieldName, $p_defaultValue)
 {
     $p_fieldType = strtolower($p_fieldType);
     if (!in_array($p_fieldType, array('ci', 'cs', 'num'))) {
         $p_fieldType = 'ci';
     }
     $queries = array();
     // all possible custom fields are taken alike for constraints
     $fields = ArticleTypeField::FetchFields($p_fieldName, $p_articleType, null, false, false, false, true, true);
     if (!empty($fields)) {
         foreach ($fields as $fieldObj) {
             $art_type = 'X' . $fieldObj->getArticleType();
             $query = '        SELECT ' . $art_type . '.' . $fieldObj->getName() . ' FROM ' . $art_type . ' ' . 'WHERE ' . $art_type . '.NrArticle = Articles.Number ' . 'AND ' . $art_type . '.IdLanguage = Articles.IdLanguage';
             $queries[] = $query;
         }
     }
     if (empty($queries)) {
         $queries[] = 'SELECT 1';
     }
     $queries_str = implode("       union\n", $queries);
     $res_query = '';
     if ('num' == $p_fieldType) {
         $p_defaultValue = 0 + $p_defaultValue;
         // if no table/row is find, the default value is used, this is done numerically
         $res_query = '(SELECT 0 + COALESCE((' . $queries_str . '), ' . $p_defaultValue . '))';
     } elseif ('cs' == $p_fieldType) {
         // <p> tag is removed, since it can be the initial tag at text area fields
         $p_defaultValue = str_replace('\'', '\'\'', $p_defaultValue);
         // if no table/row is find, the default value is used, this is done case sensitive
         $res_query = '(SELECT REPLACE(COALESCE((' . $queries_str . '), \'' . $p_defaultValue . '\'), "<p>", ""))';
     } else {
         // 'ci'
         // <p> tag is removed, since it can be the initial tag at text area fields
         $p_defaultValue = strtolower(str_replace('\'', '\'\'', $p_defaultValue));
         // if no table/row is find, the default value is used, this is done case insensitive
         $res_query = '(SELECT REPLACE(LOWER(CONVERT(COALESCE((' . $queries_str . '), \'' . $p_defaultValue . '\') USING utf8)), "<p>", ""))';
     }
     return $res_query;
 }
コード例 #5
0
ファイル: ArticleType.php プロジェクト: nidzix/Newscoop
 /**
  * Return an array of ArticleTypeField objects.
  *
  * @return array
  */
 public function getUserDefinedColumns($p_fieldName = null, $p_selectHidden = true, $p_skipCache = false)
 {
     if (is_null($p_fieldName)) {
         if ($p_skipCache || is_null($this->m_dbColumns)) {
             $this->m_dbColumns = ArticleTypeField::FetchFields(null, $this->m_name, 'NULL', false, false, true, true, $p_skipCache);
             $this->m_publicFields = array();
             foreach ($this->m_dbColumns as $field) {
                 if (!$field->isHidden()) {
                     $this->m_publicFields[] = $field;
                 }
             }
         }
         return $p_selectHidden ? $this->m_dbColumns : $this->m_publicFields;
     }
     return ArticleTypeField::FetchFields($p_fieldName, $this->m_name, 'NULL', false, false, true, $p_selectHidden, $p_skipCache);
 }