NewsNewsFeaturesDownloadsDevelopmentSupportForumDocumentsAbout Us

CustomFieldsValues 類別 參考文件
[DAO]

類別CustomFieldsValues的繼承圖:

Model Object 全部成員列表

公開方法(Public Methods)

 CustomFieldsValues ()
 getCustomFieldValue ($id)
 getArticleCustomFieldsValues ($articleId, $blogId, $includeHidden=true)
 getArticleCustomFieldValue ($fieldId, $articleId)
 addCustomFieldValue ($fieldId, $fieldValue, $articleId, $blogId)
 removeCustomFieldValue ($id)
 removeCustomFieldValues ($fieldId)
 removeArticleCustomFields ($articleId)
 updateCustomFieldValue ($fieldValue)

私有方法(Private Methods)

 getArticleCustomFieldsValuesByIds ($articleIds, $blogId, $includeHidden=true)
 _fillCustomFieldValueInformation ($row)

詳細描述

Model for the values given to certain custom fields

定義在 customfieldsvalues.class.php 檔案之第 13 行.


建構子與解構子說明文件

CustomFieldsValues::CustomFieldsValues  ) 
 

定義在 customfieldsvalues.class.php 檔案之第 16 行.

參考 Model::Model().

00017         {
00018             $this->Model();
00019         }


函式成員說明文件

CustomFieldsValues::_fillCustomFieldValueInformation row  )  [private]
 

定義在 customfieldsvalues.class.php 檔案之第 232 行.

參考 CustomFieldValueFactory::getCustomFieldValueObject().

被參考於 getArticleCustomFieldsValues(), getArticleCustomFieldsValuesByIds(), 及 getArticleCustomFieldValue().

00233         {
00234             return CustomFieldValueFactory::getCustomFieldValueObject( $row );
00235         }

CustomFieldsValues::addCustomFieldValue fieldId,
fieldValue,
articleId,
blogId
 

adds a custom field value to the given article

參數:
fieldId 
fieldValue 
articleId 
blogId 
傳回值:
True if successful or false otherwise

定義在 customfieldsvalues.class.php 檔案之第 158 行.

參考 $query, $result, Model::Execute(), 及 Db::qstr().

00159         {
00160             $filter = new Textfilter();
00161             $query = "INSERT INTO ".$this->getPrefix()."custom_fields_values
00162                       (field_id, field_value, normalized_value, blog_id, article_id)
00163                       VALUES (
00164                       $fieldId, '".Db::qstr($fieldValue)."','".
00165                       $filter->normalizeText(Db::qstr($fieldValue))."',
00166                       $blogId, $articleId
00167                       )";
00168                       
00169             $result = $this->Execute( $query );
00170             
00171             return $result;
00172         }

CustomFieldsValues::getArticleCustomFieldsValues articleId,
blogId,
includeHidden = true
 

returns an array of CustomFieldValue objects with information about all the custom fields available for an article

參數:
articleId The id of the article
the blog id to which the fields belong
includeHidden Whether to return hidden fields or not
傳回值:
An array of CustomFieldValue objects, or false if error

定義在 customfieldsvalues.class.php 檔案之第 49 行.

參考 $query, $result, _fillCustomFieldValueInformation(), Model::Execute(), 及 Model::getPrefix().

00050         {                   
00051             //
00052             // it's quite a big query and has a 'right outer join', but the whole point is that
00053             // we want to obtain as many rows as fields we have available. If there is no value
00054             // for this article for one of the fields, we still want to get a row with the name
00055             // of the field, its type and so on, with 'null' values where there is no value.
00056             //
00057             $prefix = $this->getPrefix();
00058             $query = "SELECT v.id AS id, d.id AS field_id, v.field_value AS field_value, 
00059                              d.field_name AS field_name, d.field_type AS field_type, 
00060                              d.field_description AS field_description 
00061                              FROM {$prefix}custom_fields_values v 
00062                              RIGHT OUTER JOIN {$prefix}custom_fields_definition d 
00063                              ON v.article_id = $articleId AND v.field_id = d.id
00064                              WHERE d.blog_id = '".Db::qstr($blogId)."'";
00065             if( !$includeHidden )
00066                 $query .= " AND d.hidden = 0 ";
00067             $query .= " ORDER BY date ASC";
00068                       
00069             $result = $this->Execute( $query );
00070             
00071             $fields = Array();
00072                         
00073             // return empty array if no fields
00074             if( !$result )
00075                 return $fields;
00076             
00077             while( $row = $result->FetchRow()) {
00078                 $field = $this->_fillCustomFieldValueInformation( $row );
00079                 $fields[$field->getName()] = $field;
00080             }
00081         
00082             return $fields;
00083         }

CustomFieldsValues::getArticleCustomFieldsValuesByIds articleIds,
blogId,
includeHidden = true
[private]
 

參閱:
getArticleCustomFieldsValues

定義在 customfieldsvalues.class.php 檔案之第 89 行.

參考 $query, $result, _fillCustomFieldValueInformation(), Model::Execute(), Model::getPrefix(), 及 Db::qstr().

00090         {                   
00091             //
00092             // it's quite a big query and has a 'right outer join', but the whole point is that
00093             // we want to obtain as many rows as fields we have available. If there is no value
00094             // for this article for one of the fields, we still want to get a row with the name
00095             // of the field, its type and so on, with 'null' values where there is no value.
00096             //
00097             $prefix = $this->getPrefix();
00098             $query = "SELECT v.article_id as article_id, v.id AS id, d.id AS field_id, v.field_value AS field_value, 
00099                              d.field_name AS field_name, d.field_type AS field_type, 
00100                              d.field_description AS field_description 
00101                              FROM {$prefix}custom_fields_values v 
00102                              RIGHT OUTER JOIN {$prefix}custom_fields_definition d 
00103                              ON v.article_id IN (".$articleIds.") AND v.field_id = d.id
00104                              WHERE d.blog_id = '".Db::qstr($blogId)."'";
00105             if( !$includeHidden )
00106                 $query .= " AND d.hidden = 0 ";
00107             $query .= " ORDER BY date ASC";
00108                       
00109             $result = $this->Execute( $query );
00110             
00111             //$fields = Array();
00112                         
00113             // return empty array if no fields
00114             if( !$result )
00115                 return $fields;
00116             
00117             while ($row = $result->FetchRow()) {
00118                 $lastArticleId=$row["article_id"];
00119                 $field = $this->_fillCustomFieldValueInformation( $row );
00120                 $fields[$lastArticleId][$field->getName()] = $field;
00121             }
00122         
00123             return $fields;
00124         }

CustomFieldsValues::getArticleCustomFieldValue fieldId,
articleId
 

參數:
fieldId 
articleId 
傳回值:
A CustomFieldValue object

定義在 customfieldsvalues.class.php 檔案之第 132 行.

參考 $query, $result, _fillCustomFieldValueInformation(), 及 Model::Execute().

00133         {
00134             $query = "SELECT * FROM ".$this->getPrefix()."custom_fields_values
00135                       WHERE field_id = $fieldId AND article_id = $articleId
00136                       ORDER BY date ASC";
00137                       
00138             $result = $this->Execute( $query );
00139                         
00140             if( !$result )
00141                 return false;
00142             
00143             $row = $result->FetchRow();
00144             $fieldValue = $this->_fillCustomFieldValueInformation( $row );
00145         
00146             return $fieldValue;
00147         }

CustomFieldsValues::getCustomFieldValue id  ) 
 

gets the value associated to the custom field with the given id

參數:
id The id of the custom field value
傳回值:
A CustomFieldValue object

定義在 customfieldsvalues.class.php 檔案之第 27 行.

參考 $query, $result, 及 Model::Execute().

00028         {
00029             $query = "SELECT * FROM ".$this->getPrefix()."custom_fields_values
00030                       WHERE id = $id ORDER BY date ASC";
00031                       
00032             $result = $this->Execute( $query );
00033             
00034             if( !$result )
00035                 return false;
00036             else
00037                 return $this->_fillCustomFieldInformation( $result->FetchRow());
00038         }

CustomFieldsValues::removeArticleCustomFields articleId  ) 
 

Removes all the values associated to an article

參數:
articleId 
傳回值:
True if deleted successfully or false otherwise.

定義在 customfieldsvalues.class.php 檔案之第 214 行.

參考 $query, $result, 及 Model::Execute().

00215         {
00216             $query = "DELETE FROM ".$this->getPrefix()."custom_fields_values
00217                       WHERE article_id = $articleId"; 
00218                       
00219             $result = $this->Execute( $query );
00220             
00221             return $result;
00222         }

CustomFieldsValues::removeCustomFieldValue id  ) 
 

removes a value of a custom field, given its id.

參數:
id 
傳回值:
True if deleted successfully or false otherwise.

定義在 customfieldsvalues.class.php 檔案之第 181 行.

參考 $query, $result, 及 Model::Execute().

00182         {
00183             $query = "DELETE FROM ".$this->getPrefix()."custom_fields_values
00184                       WHERE id = $id";
00185                       
00186             $result = $this->Execute( $query );
00187             
00188             return $result;
00189         }

CustomFieldsValues::removeCustomFieldValues fieldId  ) 
 

Removes all the values associated to a certain custom field

參數:
fieldId 
傳回值:
True if successful or false otherwise.

定義在 customfieldsvalues.class.php 檔案之第 197 行.

參考 $query, $result, 及 Model::Execute().

00198         {
00199             $query = "DELETE FROM ".$this->getPrefix()."custom_fields_values
00200                       WHERE field_id = $fieldId";
00201                       
00202             $result = $this->Execute( $query );
00203             
00204             return $result;
00205         }

CustomFieldsValues::updateCustomFieldValue fieldValue  ) 
 

定義在 customfieldsvalues.class.php 檔案之第 224 行.

00225         {
00226         
00227         }


此類別(class) 文件是由下列檔案中產生: