Index: trunk/kernel/include/item.php =================================================================== diff -u -r3122 -r3145 --- trunk/kernel/include/item.php (.../item.php) (revision 3122) +++ trunk/kernel/include/item.php (.../item.php) (revision 3145) @@ -20,6 +20,8 @@ var $ReviewSortOrder; var $ReviewPerPageVar; + var $TitleField = ''; + function clsItem($FullItem=FALSE) { $this->clsParsedItem(); @@ -1106,6 +1108,33 @@ $sql = 'SELECT ParentId FROM '.$prefix.'Category WHERE CategoryId = '.$cat_id; if($cat_id > 0) $this->refreshLastUpdate( $db->GetOne($sql) ); } + + function StripDisallowed($string) + { + $not_allowed = Array(' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|'); + $string = str_replace($not_allowed, '_', $string); + return preg_replace('/(_+)/', '_', $string); + } + function GenerateFilename() + { + if ( !$this->Get('AutomaticFilename') && $this->Get('Filename') ) return false; + $name = $this->StripDisallowed( $this->Get($this->TitleField) ); + if ( $name != $this->Get('Filename') ) $this->Set('Filename', $name); + } + + function Update($UpdatedBy = null) + { + $this->GenerateFilename(); + parent::Update($UpdatedBy); + + } + + function Create() + { + $this->GenerateFilename(); + parent::Create(); + } + } ?> \ No newline at end of file