Hey. Fantastic. I love the changes. Thank you for that.
I finally decided to dig into the code and fix a couple of small problems to make it ready for production.
1. I decided to make the date options a config setting, so people can change it themselves to a format they prefer.
config.php
Code:
/**
* ZAD folder formats
*/
$GLOBALS['TL_ZAD']['formats']['year'] = 'Y';
$GLOBALS['TL_ZAD']['formats']['month'] = 'Ym';
$GLOBALS['TL_ZAD']['formats']['day'] = 'Ymd';
Then add this to the ZadSendNewsManager.php
Code:
private function check()
...
...
// set attachment folder
$this->folder = $this->manager->enclosure_dir;
// modified by thyon
$this->folder .= '/' . date($GLOBALS['TL_ZAD']['formats'][$this->manager->enclosure_dirtype], time());
// fix the directory check function
if (!is_dir(TL_ROOT . '/' . $this->folder)) {
// create directory
mkdir($this->folder);
}
...
}
2. set an automatic teaser anyway, even if there isn't a rule
Code:
private function importNews() {
...
// add default auto-teaser at first full stop or 80 chars
$this->import('String');
$pos = max(80, (strpos($this->text, '.')+1));
$this->news['teaser'] = $this->String->substr($this->text, $pos, ($pos == 80));
...
}
3. Remove the inline image if it was inserted as main image (singleSRC). I would also remove the floating=left setting, because I normally control that via CSS, so it's just not necessary to set that up.
Code:
private function imageManagement(&$import) {
...
case 'first':
if ($first) {
// save as news icon
$filename = $this->saveFile($img);
$import['addImage'] = '1';
$import['singleSRC'] = $filename;
//$import['floating'] = 'left';
// remove image from list
$search = array(
'#<img(\s[^>]*)?\ssrc\s*=\s*"cid:'.$img['cid'].'"(\s[^>]*)?>#is',
'#<img(\s[^>]*)?\ssrc\s*=\s*"'.$img['cid'].'"(\s[^>]*)?>#is');
$replace = '';
$count = 0;
$this->news['html'] = preg_replace($search, $replace, $this->news['html'], -1, $count);
} else {
// save as file attachment
$this->news['files'][] = $img;
}
break;
...
}
Now it's ready for production to my clients. Thanks. Thanks. Thanks.
Bookmarks