Inherits DataItem.
Definition at line 8 of file content_version.inc.
◆ approve()
ContentVersion::approve |
( |
|
$target | ) |
|
Definition at line 188 of file content_version.inc.
192 $tx =
new DataTransaction();
195 $this->joinTransaction(
$tx);
200 $this->approved_by =
$user->getPrimaryKeyValue();
201 $this->approved_date = now();
◆ ApprovedBy()
ContentVersion::ApprovedBy |
( |
| ) |
|
Definition at line 271 of file content_version.inc.
274 return $mgr->getUser($this->approved_by);
Provides the interface to the user model for the application.
◆ approvedVersions()
static ContentVersion::approvedVersions |
( |
|
$target, |
|
|
|
$includeContent = false |
|
) |
| |
|
static |
Returns an array of previously approved versions of this content item.
- Parameters
-
DataItem | $target | the target content item |
boolean | $includeContent | true to return the content from previous versions, false to exclude content |
Definition at line 129 of file content_version.inc.
131 $query = Query::create(
ContentVersion,
"WHERE content_class=:c AND content_id=:i AND approved=1 ORDER BY version_number DESC")
132 ->bind(
":c", get_class(
$target),
":i",
$target->getPrimaryKeyValue());
134 if (!$includeContent)
136 $query->filter(
new ExclusionFilter(
"content"));
139 return $query->execute();
◆ deleteDraft()
static ContentVersion::deleteDraft |
( |
|
$target | ) |
|
|
static |
Delete the current draft changes for the specified target (if they exist)
- Parameters
-
Definition at line 107 of file content_version.inc.
111 $doomed = Query::create(
ContentVersion,
"WHERE content_class=:c AND content_id=:i AND approved=0")
112 ->bind(
":c", get_class(
$target),
":i",
$target->getPrimaryKeyValue())
116 catch(DataNotFoundException $e)
118 trace(
"Draft not found", 3);
◆ getVersion()
static ContentVersion::getVersion |
( |
|
$target, |
|
|
|
$version |
|
) |
| |
|
static |
Definition at line 142 of file content_version.inc.
144 if ($version ==
"draft")
149 $contentVersion = Query::create(
ContentVersion,
"WHERE content_class=:c AND content_id=:i AND approved=0")
150 ->bind(
":c", get_class(
$target),
":i",
$target->getPrimaryKeyValue())
153 catch(DataNotFoundException $e)
155 $contentVersion =
null;
158 else if ($version ==
"")
162 $contentVersion = Query::create(
ContentVersion,
"WHERE content_class=:c AND content_id=:i AND approved=1 ORDER BY version_number DESC LIMIT 1")
163 ->bind(
":c", get_class(
$target),
":i",
$target->getPrimaryKeyValue())
166 catch(DataNotFoundException $e)
168 $contentVersion =
null;
175 $contentVersion = Query::create(
ContentVersion,
"WHERE content_class=:c AND content_id=:i AND version_number=:v AND approved=1")
176 ->bind(
":c", get_class(
$target),
":i",
$target->getPrimaryKeyValue(),
":v", $version)
179 catch(DataNotFoundException $e)
181 $contentVersion =
null;
185 return $contentVersion;
◆ hasDraft()
static ContentVersion::hasDraft |
( |
|
$target | ) |
|
|
static |
Determine whether the specified target content item has a draft version outstanding.
- Parameters
-
DataItem | $target | the target content item |
- Returns
- true if a draft version has been created, false otherwise
Definition at line 96 of file content_version.inc.
98 return Query::create(
ContentVersion,
"WHERE content_class=:c AND content_id=:i AND approved=0")
99 ->bind(
":c", get_class(
$target),
":i",
$target->getPrimaryKeyValue())
◆ LastModifiedBy()
ContentVersion::LastModifiedBy |
( |
| ) |
|
◆ loadDraft()
static ContentVersion::loadDraft |
( |
|
$target | ) |
|
|
static |
Update the versioned fields on target object to the current draft version.
- Parameters
-
DataItem | $target | the target content object |
Definition at line 71 of file content_version.inc.
75 trace(print_r(
$target,
true), 3);
77 $contentVersion = Query::create(
ContentVersion,
"WHERE content_class=:c AND content_id=:i AND approved=0")
78 ->bind(
":c", get_class(
$target),
":i",
$target->getPrimaryKeyValue())
81 $contentVersion->populateTo(
$target);
83 catch(DataNotFoundException $e)
85 trace(
"Draft not found", 3);
◆ loadVersion()
static ContentVersion::loadVersion |
( |
|
$target, |
|
|
|
$version |
|
) |
| |
|
static |
Update the versioned fields on the target object to the specified version.
- Parameters
-
DataItem | $target | the target content object |
int | $version | the target version number |
- Exceptions
-
Definition at line 218 of file content_version.inc.
220 checkNumeric($version);
223 $contentVersion = Query::create(
ContentVersion,
"WHERE content_class=:c AND content_id=:i AND version_number=:v")
224 ->bind(
":c", get_class(
$target),
":i",
$target->getPrimaryKeyValue(),
":v", $version)
227 $contentVersion->populateTo(
$target);
229 catch(DataNotFoundException $e)
FakoliException is the base exception class for all Fakoli errors.
◆ saveDraft()
static ContentVersion::saveDraft |
( |
|
$target | ) |
|
|
static |
Saves a draft version of the target object to the content version table.
- Parameters
-
DataItem | $target | the target to save |
Definition at line 28 of file content_version.inc.
32 $tx =
new DataTransaction();
37 $contentVersion = Query::create(
ContentVersion,
"WHERE content_class=:c AND content_id=:i AND approved=0")
38 ->bind(
":c", get_class(
$target),
":i",
$target->getPrimaryKeyValue())
41 catch (DataNotFoundException $e)
44 $contentVersion->content_class = get_class(
$target);
45 $contentVersion->content_id =
$target->getPrimaryKeyValue();
46 $contentVersion->version_number = ContentVersion::nextVersion(
$target,
$tx);
47 $contentVersion->approved =
false;
48 $contentVersion->approved_by = 0;
51 $contentVersion->last_modified_by =
$user->getPrimaryKeyValue();
52 $contentVersion->last_modified = now();
54 $contentVersion->populateFrom(
$target);
56 $contentVersion->joinTransaction(
$tx);
57 $contentVersion->save();
◆ $fields
Initial value:= array("content_version_id" => Number,
"content_class" => String,
"content_id" => Number,
"version_number" => Number,
"content" => Text,
"last_modified" => DateTime,
"last_modified_by" => Number,
"approved" => Boolean,
"approved_date" => DateTime,
"approved_by" => Number)
Definition at line 13 of file content_version.inc.
◆ $primary_key
ContentVersion::$primary_key = "content_version_id" |
◆ $table
ContentVersion::$table = "content_version" |
The documentation for this class was generated from the following file: