Beispiel #1
0
 /**
  * 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'));
     }
 }
Beispiel #2
0
 /**
  * @covers Xoops\Core\Request::getText
  */
 public function testGetText()
 {
     $varname = 'RequestTest';
     $_REQUEST[$varname] = 'Lorem ipsum </i><script>alert();</script>';
     $this->assertEquals($_REQUEST[$varname], Request::getText($varname));
 }