if( !defined("ASSET_CLASS_SET") ){ /* ** File: TheAssetClass.php3 ** Author: Vladimir A. Pshenkin ** Created: 05 Aug 2000 ** Description: definition of TheAsset class. ** Thoose class is the base class for all other IAV data structures ( Articles, Comments, Categories e.t.c. ) ** ** Methods: ** ** function TheAsset( $ASSET_ID="", $ASSET_TYPE="" ) - constructor ** ** function GetAssetAuthorID() - returns asset ID or 0 if asset is NEW and not saved ** function GetAssetAuthorScreenName() - returns author screen name or "" ** ** function GetAssetEditorID() - ** function GetAssetEditorScreenName() - ** ** function GetAssetCaption() - returns asset creation date ** function SetAssetCaption($Caption) - returns asset creation date ** ** function GetAssetPubDate() - returns asset creation date ** function GetAssetModDate() - returns asset modifcation date ** function GetAssetArchDate() - returns asset archivation date ** ** function GetAssetStatus() - returns asset status ** ** function SetAssetAuthorID($AuthorID) - ** function SetAssetEditorID($EditorID) - ** ** function SetAssetPubDate() - ** function SetAssetModDate() - ** function SetAssetArchDate() - ** ** function SetAssetStatus($STATUS) - sets asset status ** ** function SaveAsset() ** function LoadAsset($ASSET_ID) ** function LoadAsset2($RESOURCE_ID, $RESOURCE_TYPE) ** ** function ArchiveAsset() ** ** function ShowImageList() - display asset related images as table. ** ** Last modification: ** 2000-09-07 - changed ASSET database structure ** - added new functions */ $AssetDebugMode = 0; if( $AssetDebugMode ){ require "$DOCUMENT_ROOT/utils/common.php3"; } if( !defined("THE_BLOB_API") ){ require_once "$LIBRARY_ROOT/TheBlobAPI.php3"; } define("ASSETS_TABLE", "AIV_ASSET"); define("ASSET_CLASS_SET", 1); /* DATABASE STRUCTURE for ASSETS: mysql> show columns from AIV_ASSET ; +---------------+--------------------------------------------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------------------------------------------+------+-----+---------------------+----------------+ 1| ASSET_ID | int(11) | | PRI | 0 | auto_increment | 2| ASSET_TYPE | enum('','A','F','O','P','C','L','S','M','H','E') | | | | | 3| RESOURCE_ID | int(11) | | | 0 | | 4| MEMBER_AUTHOR | int(11) | | | 0 | | 5| MEMBER_EDITOR | int(11) | YES | | 0 | | 6| CAPTION | varchar(255) | YES | | NULL | | 7| PUBDATE | datetime | | | 0000-00-00 00:00:00 | | 8| MODDATE | datetime | | | 0000-00-00 00:00:00 | | 9| ARCHDATE | datetime | | | 0000-00-00 00:00:00 | | 0| STATUS | enum('N','P','E','D','A') | YES | | N | | +---------------+--------------------------------------------------+------+-----+---------------------+----------------+ 10 rows in set (0.00 sec) */ if( $SLANG == "Ru" ){ define('ASSET_LABEL_PICTURE', "Объект"); define('ASSET_LABEL_SHORTCUT', "Адрес на сайте"); }else{ define('ASSET_LABEL_PICTURE', "Objects"); define('ASSET_LABEL_SHORTCUT', "Site relative URL"); } class TheAsset { var $ASSET_ID; var $ASSET_TYPE; var $RESOURCE_ID; var $MEMBER_AUTHOR; var $MEMBER_AUTHOR_NAME; var $MEMBER_EDITOR; var $MEMBER_EDITOR_NAME; var $CAPTION; var $PUBDATE; var $MODDATE; var $ARCHDATE; var $STATUS; var $error; // not null if error occurs // constructor // $ASSET_ID - internal asset ID ( int ) // $ASSET_TYPE - asset type ( 'ARTICLE', 'CATEGORY', 'COMMENT', e.t.c. ) ( string ) function LoadAsset($OLD_ASSET_ID){ global $DB, $DBID; $this->error = 0; $SQL = "SELECT AIV_ASSET.*, AIV_MEMBER1.login as author, AIV_MEMBER2.login as editor FROM AIV_ASSET ". "LEFT JOIN AIV_MEMBER as AIV_MEMBER1 on AIV_MEMBER1.id=AIV_ASSET.MEMBER_AUTHOR ". "LEFT JOIN AIV_MEMBER as AIV_MEMBER2 on AIV_MEMBER2.id=AIV_ASSET.MEMBER_EDITOR ". "WHERE ASSET_ID='$OLD_ASSET_ID'"; $result = GetObject($DB, $SQL); if( $result ){ $this->ASSET_ID = $result["ASSET_ID"]; $this->ASSET_TYPE = $result["ASSET_TYPE"]; $this->RESOURCE_ID = $result["RESOURCE_ID"]; $this->MEMBER_AUTHOR = $result["MEMBER_AUTHOR"]; $this->MEMBER_AUTHOR_NAME = $result["author"]; $this->MEMBER_EDITOR = $result["MEMBER_EDITOR"]; $this->MEMBER_EDITOR_NAME = $result["editor"]; $this->CAPTION = $result["CAPTION"]; $this->PUBDATE = $result["PUBDATE"]; $this->MODDATE = $result["MODDATE"]; $this->ARCHDATE = $result["ARCHDATE"]; $this->STATUS = $result["STATUS"]; // $this-> = $result[""); $this->error = 0; }else{ $this->error = 1; } } /* LoadAsset() */ function LoadAsset2($OLD_RESOURCE_ID, $OLD_RESOURCE_TYPE){ global $DB, $DBID; $this->error = 0; $SQL = "SELECT AIV_ASSET.*, AIV_MEMBER1.login as author, AIV_MEMBER2.login as editor FROM AIV_ASSET ". "LEFT JOIN AIV_MEMBER as AIV_MEMBER1 on AIV_MEMBER1.id=AIV_ASSET.MEMBER_AUTHOR ". "LEFT JOIN AIV_MEMBER as AIV_MEMBER2 on AIV_MEMBER2.id=AIV_ASSET.MEMBER_EDITOR ". "WHERE RESOURCE_ID='$OLD_RESOURCE_ID' and ASSET_TYPE='$OLD_RESOURCE_TYPE'"; // echo ""; $result = GetObject($DB, $SQL); if( $result ){ $this->ASSET_ID = $result["ASSET_ID"]; $this->ASSET_TYPE = $result["ASSET_TYPE"]; $this->RESOURCE_ID = $result["RESOURCE_ID"]; $this->MEMBER_AUTHOR = $result["MEMBER_AUTHOR"]; $this->MEMBER_AUTHOR_NAME = $result["author"]; $this->MEMBER_EDITOR = $result["MEMBER_EDITOR"]; $this->MEMBER_EDITOR_NAME = $result["editor"]; $this->CAPTION = $result["CAPTION"]; $this->PUBDATE = $result["PUBDATE"]; $this->MODDATE = $result["MODDATE"]; $this->ARCHDATE = $result["ARCHDATE"]; $this->STATUS = $result["STATUS"]; // $this-> = $result[""]; $this->error = 0; }else{ $this->error = 1; } } /* LoadAsset2() */ function SaveAsset(){ global $DB, $DBID; if( ($this->ASSET_ID != "") && ($this->ASSET_ID > 0 ) ){ $this->CAPTION = addslashes($this->CAPTION); $SQL = "UPDATE AIV_ASSET SET RESOURCE_ID='$this->RESOURCE_ID', ASSET_TYPE='$this->ASSET_TYPE', " . "MEMBER_AUTHOR='$this->MEMBER_AUTHOR', MEMBER_EDITOR='$this->MEMBER_EDITOR', " . "PUBDATE='$this->PUBDATE', " . "CAPTION='$this->CAPTION', MODDATE=now(), STATUS='$this->STATUS' WHERE ASSET_ID='$this->ASSET_ID' "; // echo " SAV: " . $SQL; $result = DBExec($DB, $SQL); $this->LoadAsset($this->ASSET_ID); } } /* SaveAsset() */ function GetTheAsset3( $NEW_RESOURCE_ID, $NEW_RESOURCE_TYPE, $AuthorID ){ global $DB, $DBID; $this->error = 0; // echo "3:"; // create new asset from scratch // $ASSET_ID param is a RESOURCE_ID !!! $SQL = "INSERT INTO AIV_ASSET ( RESOURCE_ID, MEMBER_AUTHOR, ASSET_TYPE, PUBDATE, STATUS ) " . " VALUES ('$NEW_RESOURCE_ID', '$AuthorID', '$NEW_RESOURCE_TYPE', now(), 'N' )"; // echo $SQL ; DBExec($DB, $SQL); $this->ASSET_ID = mysqli_insert_id($DB); $this->LoadAsset($this->ASSET_ID); } function GetTheAsset2($OLD_RESOURCE_ID, $OLD_RESOURCE_TYPE){ global $DB; $this->error = 0; // echo "2:"; // load assset VIA ResurceID/ResourceType interface $this->LoadAsset2($OLD_RESOURCE_ID, $OLD_RESOURCE_TYPE); } function GetTheAsset1( $OLD_ASSET_ID ){ global $DB; $this->error = 0; // echo "1:"; // get asset info from DB directly by ASSET_ID $this->LoadAsset($OLD_ASSET_ID); } function GetAssetAuthorID(){ return $this->MEMBER_AUTHOR; } function GetAssetAuthorScreenName(){ return $this->MEMBER_AUTHOR_NAME; } function GetAssetEditorID(){ return $this->MEMBER_EDITOR; } function GetAssetEditorScreenName(){ return $this->MEMBER_EDITOR_NAME; } function GetAssetPubDate(){ return $this->PUBDATE; } function GetAssetModDate(){ return $this->MODDATE; } function GetAssetArchDate(){ return $this->ARCHDATE; } function GetAssetStatus(){ return $this->STATUS; } function SetAssetAuthorID($AuthorID){ $User = GetUserByID($AuthorID); $CurrAuthor = $this->MEMBER_AUTHOR ; if( is_object($User) ){ $this->MEMBER_AUTHOR = $AuthorID; $this->MEMBER_AUTHOR_NAME = $User->login ; }else{ $this->MEMBER_AUTHOR = 0; $this->MEMBER_AUTHOR_NAME = ""; } return $CurrAuthor; } function SetAssetEditorID($EditorID){ $User = GetUserByID($EditorID); $CurrEditor = $this->MEMBER_EDITOR ; if( is_object($User) ){ $this->MEMBER_EDITOR = $EditorID; $this->MEMBER_EDITOR_NAME = $User->login ; }else{ $this->MEMBER_EDITOR = 0; $this->MEMBER_EDITOR_NAME = ""; } return $CurrEditor; } function SetAssetPubDate(){ return $this->PUBDATE; } function SetAssetModDate(){ return $this->MODDATE; } function SetAssetArchDate(){ return $this->ARCHDATE; } function SetAssetStatus($STATUS){ $currStatus = $this->STATUS; $this->STATUS = $STATUS; return $currStatus; } function ArchiveAsset(){ } function GetAssetCaption(){ return $this->CAPTION ; } // - returns asset creation date function SetAssetCaption($Caption){ $currCAPTION = $this->CAPTION; $this->CAPTION = $Caption; return $currCAPTION; } // - returns asset creation date function ShowImageList($ClassName, $Title = "Images", $ImageSet = "PICT", $AttachType='IMAGE' ){ // var_dump($this); // echo $AttachType ; global $DB; if( (!isset($this->ASSET_ID)) || ($this->ASSET_ID=="") ){ return ; } ?>
=$Title?>
=ASSET_LABEL_PICTURE?> | =ASSET_LABEL_SHORTCUT?> |
---|---|
echo $AHOpen . $ObjectLink . $AHClose; ?> echo $Warn; ?> | " onfocus="AttImgFocus()"> | */ } }else{ $ExistingImagesCnt = 0; } // @mysql_free_result($result); if( $ExistingImagesCnt<$TBlob->CDL_MAX_PER_ASSET ){ for($image=$ExistingImagesCnt; $image<$TBlob->CDL_MAX_PER_ASSET; $image++ ){ /*
![]() |