/** * @param string $post_field * @param array $allowed_mimetypes * @param array $errors * * @return bool */ public function storeUpload($post_field, $allowed_mimetypes = array(), &$errors) { $itemid = $this->getVar('itemid'); if (empty($allowed_mimetypes)) { $allowed_mimetypes = $this->publisher->getMimetypeHandler()->getArrayByType(); } $maxfilesize = $this->publisher->getConfig('maximum_filesize'); $maxfilewidth = $this->publisher->getConfig('maximum_image_width'); $maxfileheight = $this->publisher->getConfig('maximum_image_height'); if (!is_dir(PublisherUtils::getUploadDir())) { mkdir(PublisherUtils::getUploadDir(), 0757); } $uploader = new XoopsMediaUploader(PublisherUtils::getUploadDir() . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); if ($uploader->fetchMedia($post_field)) { $uploader->setTargetFileName($itemid . "_" . $uploader->getMediaName()); if ($uploader->upload()) { $this->setVar('filename', $uploader->getSavedFileName()); if ($this->getVar('name') == '') { $this->setVar('name', $this->getNameFromFilename()); } $this->setVar('mimetype', $uploader->getMediaType()); return true; } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } }
/** * @return string */ public function createMetaKeywords() { $keywords = $this->findMetaKeywords($this->_original_title . " " . $this->_description, $this->_minChar); $moduleKeywords = $this->publisher->getConfig('seo_meta_keywords'); if ($moduleKeywords != '') { $moduleKeywords = explode(",", $moduleKeywords); $keywords = array_merge($keywords, array_map('trim', $moduleKeywords)); } $ret = implode(',', $keywords); return $ret; }
/** * The name says it all */ public function setVarsFromRequest() { $xoops = Xoops::getInstance(); //Required fields if (isset($_REQUEST['categoryid'])) { $this->setVar('categoryid', Request::getInt('categoryid')); } if (isset($_REQUEST['title'])) { $this->setVar('title', Request::getString('title')); } if (isset($_REQUEST['body'])) { $this->setVar('body', Request::getText('body')); } //Not required fields if (isset($_REQUEST['summary'])) { $this->setVar('summary', Request::getText('summary')); } if (isset($_REQUEST['subtitle'])) { $this->setVar('subtitle', Request::getString('subtitle')); } if (isset($_REQUEST['item_tag'])) { $this->setVar('item_tag', Request::getString('item_tag')); } if (isset($_REQUEST['image_featured'])) { $image_item = Request::getArray('image_item'); $image_featured = Request::getString('image_featured'); //Todo: get a better image class for xoops! //Image hack $image_item_ids = array(); $qb = \Xoops::getInstance()->db()->createXoopsQueryBuilder(); $qb->select('i.image_id', 'i.image_name')->fromPrefix('image', 'i')->orderBy('i.image_id'); $result = $qb->execute(); while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) { $image_name = $myrow['image_name']; $id = $myrow['image_id']; if ($image_name == $image_featured) { $this->setVar('image', $id); } if (in_array($image_name, $image_item)) { $image_item_ids[] = $id; } } $this->setVar('images', implode('|', $image_item_ids)); } if (isset($_REQUEST['uid'])) { $this->setVar('uid', Request::getInt('uid')); } elseif ($this->isNew()) { $this->setVar('uid', $xoops->isUser() ? $xoops->user->getVar('uid') : 0); } if (isset($_REQUEST['author_alias'])) { $this->setVar('author_alias', Request::getString('author_alias')); if ($this->getVar('author_alias') != '') { $this->setVar('uid', 0); } } if (isset($_REQUEST['datesub'])) { $this->setVar('datesub', strtotime($_REQUEST['datesub']['date']) + $_REQUEST['datesub']['time']); } elseif ($this->isNew()) { $this->setVar('datesub', time()); } if (isset($_REQUEST['item_short_url'])) { $this->setVar('short_url', Request::getString('item_short_url')); } if (isset($_REQUEST['item_meta_keywords'])) { $this->setVar('meta_keywords', Request::getString('item_meta_keywords')); } if (isset($_REQUEST['item_meta_description'])) { $this->setVar('meta_description', Request::getString('item_meta_description')); } if (isset($_REQUEST['weight'])) { $this->setVar('weight', Request::getInt('weight')); } if (isset($_REQUEST['allowcomments'])) { $this->setVar('cancomment', Request::getInt('allowcomments')); } elseif ($this->isNew()) { $this->setVar('cancoment', $this->publisher->getConfig('submit_allowcomments')); } if (isset($_REQUEST['status'])) { $this->setVar('status', Request::getInt('status')); } elseif ($this->isNew()) { $this->setVar('status', $this->publisher->getConfig('submit_status')); } if (isset($_REQUEST['dohtml'])) { $this->setVar('dohtml', Request::getInt('dohtml')); } elseif ($this->isNew()) { $this->setVar('dohtml', $this->publisher->getConfig('submit_dohtml')); } if (isset($_REQUEST['dosmiley'])) { $this->setVar('dosmiley', Request::getInt('dosmiley')); } elseif ($this->isNew()) { $this->setVar('dosmiley', $this->publisher->getConfig('submit_dosmiley')); } if (isset($_REQUEST['doxcode'])) { $this->setVar('doxcode', Request::getInt('doxcode')); } elseif ($this->isNew()) { $this->setVar('doxcode', $this->publisher->getConfig('submit_doxcode')); } if (isset($_REQUEST['doimage'])) { $this->setVar('doimage', Request::getInt('doimage')); } elseif ($this->isNew()) { $this->setVar('doimage', $this->publisher->getConfig('submit_doimage')); } if (isset($_REQUEST['dolinebreak'])) { $this->setVar('dobr', Request::getInt('dolinebreak')); } elseif ($this->isNew()) { $this->setVar('dobr', $this->publisher->getConfig('submit_dobr')); } if (isset($_REQUEST['notify'])) { $this->setVar('notifypub', Request::getInt('notify')); } }