Source of file CopyFactoryLog.php
Size: 4,594 Bytes - Last Modified: 2021-12-23T10:39:14+00:00
/var/www/docs.ssmods.com/process/src/code/model/CopyFactoryLog.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 | <?php /** * keeps track of any changes being made, fake or real * * */ class CopyFactoryLog extends DataObject { /** * we can write faster to MyISAM? * */ private static $create_table_options = array( 'MySQLDatabase' => 'ENGINE=MyISAM' ); private static $db = array( "StartTime" => "SS_Datetime", "Type" => "Enum('Unknown,Fake,Real', 'Unknown')", "CopyCausingClassName" => "Varchar(200)", "CopyCausingClassNameID" => "Int", "CopyFromClassNameID" => "Int", "CopyIntoClassName" => "Varchar(200)", "CopyIntoClassNameID" => "Int", "Action" => "Text" ); private static $indexes = array( "CopyCausingClassName" => true, "CopyCausingClassNameID" => true, "CopyFromClassNameID" => true, "CopyIntoClassName" => true, "CopyIntoClassNameID" => true ); private static $summary_fields = array( "StartTime", "Type", "CopyCause", "CopyFrom", "CopyInto", "FormattedShortAction" ); private static $field_labels = array( "StartTime" => "Started", "Type" => "Real or Fake", "CopyCause" => "Started by", "CopyFrom" => "From", "CopyInto" => "Into", "Action" => "Description" ); private static $searchable_fields = array( "Type" => "PartialMatchFilter", "Action" => "PartialMatchFilter" ); private static $casting = array( "CopyCause" => "Varchar", "CopyFrom" => "Varchar", "CopyInto" => "Varchar", "FormattedShortAction" => "HTMLText" ); private static $default_sort = "Created ASC"; public function canEdit($member = null) { return false; } public function canDelete($member = null) { return false; } public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab( "Root.Main", new ReadonlyField( "CopyCause", _t("CopyFactory.COPY_CAUSE", "Copy initiated by"), $this->getCopyCause() ), "CopyCausingClassName" ); $fields->addFieldToTab( "Root.Main", new ReadonlyField( "CopyFrom", _t("CopyFactory.COPY_FROM", "Copying from"), $this->getCopyFrom() ), "CopyFromClassNameID" ); $fields->addFieldToTab( "Root.Main", new ReadonlyField( "CopyInto", _t("CopyFactory.COPY_INTO", "Copying into"), $this->getCopyInto() ), "CopyIntoClassName" ); $fields->addFieldToTab( "Root.Main", new LiteralField( "Action", "<pre>$this->Action</pre>" ) ); return $fields; } /** * Copy Causer Description * @casted * @return Str */ public function getCopyCause() { $className = $this->CopyCausingClassName; if ($className) { $obj = $className::get()->byID($this->CopyCausingClassNameID); if ($obj) { return CopyFactory::title_for_object($obj)." (".$className.")"; } } return _t("CopyFactory.N_A", "n/a"); } /** * Copy From Description * @casted * @return Str */ public function getCopyFrom() { $className = $this->CopyIntoClassName; if ($className) { $obj = $className::get()->byID($this->CopyFromClassNameID); if ($obj) { return CopyFactory::title_for_object($obj)." (".$className.")"; } } return _t("CopyFactory.N_A", "n/a"); } /** * Copy Into Description * @casted * @return Str */ public function getCopyInto() { $className = $this->CopyIntoClassName; if ($className) { $obj = $className::get()->byID($this->CopyIntoClassNameID); if ($obj) { return CopyFactory::title_for_object($obj)." (".$className.")"; } } return _t("CopyFactory.N_A", "n/a"); } /** * Copy Into Description * @casted * @return Str */ public function getFormattedShortAction() { return DBField::create_field("HTMLText", str_replace("\n", "<br />", trim(substr($this->Action, 0, 799)))); } } |