Exemple #1
0
 /**
  * Resolve an url with hashbang.
  *
  * @param Url $url
  *
  * @return string
  */
 protected static function hashBang(Url $url)
 {
     if ($path = preg_replace('|^(/?!)|', '', $url->getFragment())) {
         return $url->withPath($url->getPath() . $path)->getUrl();
     }
     return $url->getUrl();
 }
Exemple #2
0
 /**
  * retrieves a list from a database
  * @param array $searchcriteria supplied criteria
  * @param integer $pagesize size of result
  * @param integer $page offset
  * @param integer $order type of order
  * @return array
  */
 public function getList($searchcriteria = NULL, $pagesize = 0, $page = 1, $order = NULL)
 {
     $sqlParser = clone $this->sqlParser;
     $sqlParser->parseCriteria($searchcriteria);
     $this->parseCriteria($sqlParser, $searchcriteria);
     $sqlParser->setOrderby($this->getOrder($order));
     $query = $sqlParser->getSql(SqlParser::SEL_LIST);
     //if($sqlParser->getTable() == 'siteplugin') echo $query."<br />\n";
     //if($sqlParser->getTable() == 'users') Utils::debug($query);
     $db = $this->getDb();
     $this->pagerUrl->setParameter($this->getPagerKey(), '%d', false);
     //Pager replaces "%d" with the page number
     $this->pagerOptions['perPage'] = $pagesize;
     $this->pagerOptions['currentPage'] = $page;
     $this->pagerOptions['fileName'] = $this->pagerUrl->getUrl(false);
     $res = Pager_Wrapper_MDB2($db, $query, $this->pagerOptions, $pagesize == 0);
     if ($db->isError($res)) {
         throw new Exception($res->getDebugInfo());
     }
     // do postprocessing
     foreach ($res['data'] as &$item) {
         if (!$item) {
             continue;
         }
         $item['formatName'] = $this->formatName($item);
         $item = $this->handlePostGetList($item);
     }
     return $res;
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 public function getUrl()
 {
     if ($this->resolver === null) {
         $this->getResolver();
     }
     return parent::getUrl();
 }
Exemple #4
0
 /**
  * @covers StopIt\Model\Url::exchangeArray
  */
 public function testExchangeArray()
 {
     $this->emptyUrl->exchangeArray(array('Id' => 2, 'Url' => 'http://test.url', 'Updated' => '2015-06-25T00:07:00+0200'));
     $this->assertEquals(2, $this->emptyUrl->getId());
     $this->assertEquals('http://test.url', $this->emptyUrl->getUrl());
     $this->assertEquals('2015-06-25T00:07:00+0200', $this->emptyUrl->getUpdated());
 }
Exemple #5
0
 /**
  * @dataProvider getUrlDataProvider
  * @covers Magento\Catalog\Model\Product\Url::getUrl
  * @covers Magento\Catalog\Model\Product\Url::getUrlInStore
  * @covers Magento\Catalog\Model\Product\Url::getProductUrl
  *
  * @param $getUrlMethod
  * @param $routePath
  * @param $requestPathProduct
  * @param $storeId
  * @param $categoryId
  * @param $routeParams
  * @param $routeParamsUrl
  * @param $entityId
  * @param $idPath
  * @param $requestPathUrlRewrite
  * @param $productId
  * @param $productUrlKey
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function testGetUrl($getUrlMethod, $routePath, $requestPathProduct, $storeId, $categoryId, $routeParams, $routeParamsUrl, $entityId, $idPath, $requestPathUrlRewrite, $productId, $productUrlKey)
 {
     $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['getStoreId', 'getEntityId', 'getId', 'getUrlKey', 'setRequestPath', 'hasUrlDataObject', 'getRequestPath', 'getCategoryId', 'getDoNotUseCategoryId', '__wakeup'])->getMock();
     $product->expects($this->any())->method('getStoreId')->will($this->returnValue($storeId));
     $product->expects($this->any())->method('getCategoryId')->will($this->returnValue($categoryId));
     $product->expects($this->any())->method('getRequestPath')->will($this->returnValue($requestPathProduct));
     $product->expects($this->any())->method('getEntityId')->will($this->returnValue($entityId));
     $product->expects($this->any())->method('setRequestPath')->with($requestPathUrlRewrite)->will($this->returnSelf());
     $product->expects($this->any())->method('getId')->will($this->returnValue($productId));
     $product->expects($this->any())->method('getUrlKey')->will($this->returnValue($productUrlKey));
     $this->url->expects($this->any())->method('setScope')->with($storeId)->will($this->returnSelf());
     $this->url->expects($this->any())->method('getUrl')->with($routePath, $routeParamsUrl)->will($this->returnValue($requestPathProduct));
     $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('loadByIdPath')->with($idPath)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('getId')->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('getRequestPath')->will($this->returnValue($requestPathUrlRewrite));
     switch ($getUrlMethod) {
         case 'getUrl':
             $this->assertEquals($requestPathProduct, $this->model->getUrl($product, $routeParams));
             break;
         case 'getUrlInStore':
             $this->assertEquals($requestPathProduct, $this->model->getUrlInStore($product, $routeParams));
             break;
         case 'getProductUrl':
             $this->assertEquals($requestPathProduct, $this->model->getProductUrl($product, true));
             $this->sidResolver->expects($this->once())->method('getUseSessionInUrl')->will($this->returnValue(true));
             $this->assertEquals($requestPathProduct, $this->model->getProductUrl($product, null));
             break;
     }
 }
 public function getNext()
 {
     if ($this->_offset < $this->_pages_count - 1) {
         echo '<li class="pagination-next"><a href="' . Url::getUrl('offset') . 'offset=' . ($this->_offset + 1) . '"></a></li>';
     } else {
         echo '<li class="pagination-next pagination-disabled"></li>';
     }
 }
 public function deleteAction()
 {
     $request = new Request();
     $id = $request->getParam('id');
     $Category = new Category();
     $Category->deleteCategory($id);
     header('location: ' . Url::getUrl('category', 'list', array('status' => 10)));
 }
Exemple #8
0
 public function registerAction()
 {
     $Auth = new Auth();
     $post = $this->request->getPost();
     if (isset($post['username'])) {
         $Auth->register($post);
         header('Location:' . Url::getUrl('user', 'login'));
     }
 }
Exemple #9
0
 public function addMarkiAction()
 {
     $Marki = new Marki();
     $post = $this->request->getPost();
     if (isset($post['marka'])) {
         $Marki->addMarki($post['marka']);
         header('Location:' . Url::getUrl('marki', 'list'));
     }
 }
Exemple #10
0
 public function __construct()
 {
     $this->request = new Request();
     $this->view = new View();
     $this->layout = new Layout();
     $this->debug = new Debug();
     if (!isset($_SESSION['login']) && ($this->request->getParam('action') !== 'login' && $this->request->getParam('action') !== 'register')) {
         header("Location:" . Url::getUrl('login', 'login'));
     }
 }
Exemple #11
0
 public function __construct()
 {
     $this->request = new Request();
     $this->view = new View();
     $this->layout = new Layout();
     $this->userStorage = new UserStorage();
     if (!$this->userStorage->isAuthenticate() && $this->request->getParam('action') !== 'login' && $this->request->getParam('action') !== 'register') {
         header('Location: ' . Url::getUrl('user', 'login'));
     }
 }
Exemple #12
0
 public function usunAction()
 {
     $id = $this->request->getParam('id');
     $Marki = new Marki();
     if ($Marki->usunMarki($id)) {
         header('Location: ' . Url::getUrl('marki', 'wypisz', null));
     } else {
         $this->view->info = 'wystapil blad bazy danych';
         header('Location: ' . Url::getUrl('marki', 'wypisz', array('info' => 'wystapil blad bazy danych')));
     }
 }
Exemple #13
0
 public function __construct()
 {
     $this->request = new Request();
     $this->view = new View();
     $this->layout = new Layout();
     $this->UserStorage = new UserStorage();
     $this->layout->info = !empty($this->request->getParam('info')) ? $this->request->getParam('info') : null;
     $this->layout->UserStorage = $this->UserStorage;
     $controller = $this->request->getParam('controller');
     $action = $this->request->getParam('action');
     if (!$this->UserStorage->isAuthenticate() && $controller != 'user' && $action != 'wyswietlLogowanie' && $action != 'loguj' && $action != 'wyswietlRejestracje' && $action != 'rejestruj') {
         header('Location: ' . Url::getUrl('user', 'wyswietlLogowanie', array('info' => 'musisz sie zalogowac')));
     } else {
         //$this->layout->wyloguj='<a href="'.Url::getUrl( 'user', 'wyloguj', null  ).'">wyloguj</a>&nbsp;</br>';
     }
 }
Exemple #14
0
 public function editAction()
 {
     $Car = new Cars();
     $this->view->data = $Car->getCategory();
     $new_model = $this->request->getPost('model');
     $new_marka = $this->request->getPost('marka_id');
     $new_opis = $this->request->getPost('opis');
     $id = $this->request->getPost('id');
     $is_photo = $this->request->getFiles('zdjecie');
     if ($new_model == NULL && $new_marka == NULL && $new_opis == NULL && $is_photo == NULL) {
         $this->view->display('edit');
     } else {
         $Car->updateCar($new_model, $new_marka, $new_opis, $is_photo, $id);
         header('location:' . Url::getUrl('car', 'list', array('status' => 6)));
     }
 }
Exemple #15
0
 public function registerAction()
 {
     $user = new Register();
     $email = $this->request->getPost('email');
     $login = $this->request->getPost('login');
     $password = md5($this->request->getPost('password'));
     if ($email == NULL && $login == NULL && $password == NULL) {
     } else {
         if ($email == NULL || $login == NULL || $password == NULL) {
         } else {
             if ($user->saveUser($email, $login, $password)) {
                 header('location=' . Url::getUrl('login', 'login', array('status' => 4)));
             } else {
                 header('location=' . Url::getUrl('register', 'register', array('status' => 5)));
             }
         }
     }
     $this->view->display('register_form');
 }
Exemple #16
0
 public function updateAutoAction()
 {
     $Cars = new Cars();
     $post = $this->request->getPost();
     if (isset($post['nazwaAuta'])) {
         $image = $this->request->getFiles('zdjecie');
         $config = Config::getInstance();
         $config = $config->getConfig();
         $plik = uniqid();
         if ($image['error'] == 0) {
             $e = pathinfo($image['name']);
             $extension = $e['extension'];
             $img = WideImage::load($image['tmp_name']);
             $resized = $img->resize(100, 100);
             $resized->saveToFile($config['IMG_DIR'] . '/small_' . $plik . '.' . $extension);
             move_uploaded_file($image['tmp_name'], $config['IMG_DIR'] . $plik . '.' . $extension);
             $post['zdjecie'] = $plik . '.' . $extension;
         }
         $Cars->editSamochody($post);
     }
     header('Location:' . Url::getUrl('cars', 'list'));
 }
Exemple #17
0
 /**
  * handle detail request
  */
 private function handleDetail()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     // it makes no sense to have multiple tags for this plugin.
     // if someone did it, you get strange results and he probably can figure out why.. no multiple detail stuff in 1 page supported!
     // so take a shot and get the first tag to set the content
     $taglist = $this->plugin->getTagList(array('plugin_type' => News::TYPE_ARCHIVE));
     if (!$taglist) {
         return;
     }
     $taginfo = current($taglist);
     // process attachments
     $attachment = $this->getAttachment();
     $attachment->handleHttpGetRequest();
     // clear subtitle
     $view->setName('');
     if (!$request->exists('id')) {
         continue;
     }
     $id = intval($request->getValue('id'));
     $key = array('id' => $id, 'active' => true);
     $overview = $this->getNewsOverview();
     if (!$overview->exists($key)) {
         throw new HttpException('404');
     }
     $detail = $overview->getDetail($key);
     // check if tree node of news item is accessable
     $tree = $this->director->tree;
     if (!$tree->exists($detail['tree_id'])) {
         throw new HttpException('404');
     }
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setPostfix($detail['tag']);
     // disable cache because we want to count visits
     $template->setCacheable(false);
     Cache::disableCache();
     // update view counter
     $overview->updateCount($key);
     // overwrite default naming
     $template->setVariable('pageTitle', $detail['name'], false);
     $template->setVariable('news', $detail, false);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $this->template[$taginfo['tag']] = $template;
 }
Exemple #18
0
<form method="post" action="<?php 
echo Url::getUrl('user', 'register');
?>
">

    username: <input type="text" name="username"></br>
    hasło: <input type="password" name="password"></br>
    <input type="submit" value="Zarejestruj się">

</form>
Exemple #19
0
 /**
  * handle breadcrumb
  */
 private function handleBreadcrumb($template)
 {
     $view = ViewManager::getInstance();
     $request = Request::getInstance();
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $template->setVariable('tree_id', $tree_id);
     $template->setVariable('tag', $tag);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter($view->getUrlId(), NewsLetter::VIEW_GROUP_OVERVIEW);
     $breadcrumb = array('name' => $view->getName(NewsLetter::VIEW_GROUP_OVERVIEW), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $this->director->theme->handleAdminLinks($template);
 }
Exemple #20
0
 public function getFileUrl($id, $htmlentities = true)
 {
     $view = ViewManager::getInstance();
     $request = Request::getInstance();
     $url_file = new Url();
     $url_file->useCurrent(false);
     $url_file->setParameter($view->getUrlId(), self::VIEW_FILE);
     $url_file->setParameter('id', $id);
     $url_file->setParameter('tag', $request->getValue('tag'));
     $url_file->setParameter('tree_id', $request->getValue('tree_id'));
     return $url_file->getUrl($htmlentities);
 }
Exemple #21
0
 /**
  * handle navigation for sub classes / pages
  */
 public function handleAdminSubLinks($keyName, $title, $addBreadcrumb = false)
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $template = new TemplateEngine();
     if (!$request->exists('nl_id')) {
         return;
     }
     $nl_id = $request->getValue('nl_id');
     $newsLetterName = $this->getName(array('id' => $nl_id));
     $template->setVariable('pageTitle', $newsLetterName, false);
     $tree_id = $request->getValue('tree_id');
     $tag = $request->getValue('tag');
     $template->setVariable('tree_id', $tree_id, false);
     $template->setVariable('tag', $tag, false);
     $template->setVariable('nl_id', $nl_id, false);
     if (!$addBreadcrumb) {
         return;
     }
     $url = new Url(true);
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     $url->setParameter('id', $nl_id);
     $url->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $breadcrumb = array('name' => $newsLetterName, 'path' => $url->getUrl(true));
     $this->addBreadcrumb($breadcrumb);
 }
Exemple #22
0
 /**
  * handle user
  */
 private function handleUserGet($retrieveFields = true)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     if (!$request->exists('id')) {
         throw new Exception('User group is missing.');
     }
     $id = intval($request->getValue('id'));
     $template->setVariable('id', $id, false);
     $key = array('id' => $id);
     $user = $this->director->adminManager->getPlugin('User');
     $usr_used = $request->getValue('usr_used');
     if ($retrieveFields) {
         $searchcriteria = array('grp_id' => $id);
         $tmp = $user->getList($searchcriteria);
         $usr_used = $tmp['data'];
     }
     $search_used = $usr_used ? array('id' => $usr_used) : NULL;
     $search_free = $usr_used ? array('no_id' => $usr_used) : NULL;
     $user_used = $usr_used ? $user->getList($search_used) : array('data' => '');
     $user_free = $user->getList($search_free);
     $template->setVariable('cbo_usr_used', Utils::getHtmlCombo($user_used['data'], NULL, NULL, 'id', 'formatName'));
     $template->setVariable('cbo_usr_free', Utils::getHtmlCombo($user_free['data'], NULL, NULL, 'id', 'formatName'));
     $view = ViewManager::getInstance();
     $url = new Url(true);
     $breadcrumb = array('name' => $view->getName(), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $url->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $template->setVariable('title', $this->getName($key), false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
 private function handleTreeSettings($template)
 {
     $view = ViewManager::getInstance();
     $request = Request::getInstance();
     if (!$request->exists('tree_id')) {
         throw new Exception('Node ontbreekt.');
     }
     if (!$request->exists('nl_id')) {
         throw new Exception('Newsletter is missing.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag ontbreekt.');
     }
     $tree_id = intval($request->getValue('tree_id'));
     $nl_id = intval($request->getValue('nl_id'));
     $tag = $request->getValue('tag');
     $template->setVariable('tree_id', $tree_id, false);
     $template->setVariable('tag', $tag, false);
     // create href back url
     $url = new Url(true);
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('nl_id', $nl_id);
     $url->setParameter('id', $nl_id);
     $url->setParameter('tag', $tag);
     $url->setParameter($view->getUrlId(), NewsLetter::VIEW_FILE_OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     // add breadcrumb item
     $breadcrumb = array('name' => $view->getName(NewsLetter::VIEW_FILE_OVERVIEW), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $this->director->theme->handleAdminLinks($template);
 }
Exemple #24
0
                    <td>
                        <a href="
                         <?php 
    echo Url::getUrl('car', 'delete', array('id' => $car['samochody_id']));
    ?>
 "> Usuń
                        </a>
                    </td>
                </tr>
            <?php 
}
?>
    </table>

    <?php 
$partial->display('pager');
?>
<br>

    <div class="nav-links">
        <h5><a href="<?php 
echo Url::getUrl('car', 'add');
?>
">Dodaj samochód</a></h5>
        <h5><a href="<?php 
echo Url::getUrl('car', 'index');
?>
">Strona Główna</a></h5>
    </div>

</section>
Exemple #25
0
 /**
  * Returns protected var $oberserver.
  * @param string observer key
  * @return array
  */
 public function getTagList($param)
 {
     $id = $param['id'];
     $tree_id = $param['tree_id'];
     $url_edit = new Url();
     $url_del = new Url();
     $url_edit->fromString($param['href_edit_theme_tag']);
     $url_del->fromString($param['href_del_theme_tag']);
     try {
         $siteTag = new SystemSiteTag();
         $theme = $this->director->themeManager->getThemeFromId(array('id' => $id));
         $usedTags = $siteTag->getTagList(array('tree_id' => $tree_id));
         $taglist = $theme->getTagList();
         foreach ($taglist as &$item) {
             $item['userdefined'] = array_key_exists($item['id'], $usedTags) ? join(', ', $usedTags[$item['id']]) : '';
             $url_edit->setParameter('parent_tag', $item['id']);
             $url_del->setParameter('parent_tag', $item['id']);
             $item['href_edit'] = $url_edit->getUrl();
             $item['href_del'] = $item['userdefined'] ? $url_del->getUrl() : '';
         }
         return array_values($taglist);
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
Exemple #26
0
 private function handleAdminUpdatePost()
 {
     $request = Request::getInstance();
     try {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $debug = $this->updateExtensions();
         $view = ViewManager::getInstance();
         $view->setType(self::VIEW_SUCCESS);
         $url = new Url(true);
         $url->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
         $template->setVariable('href_back', $url->getUrl(true), false);
         $template->setVariable('debug', is_array($debug) ? join('<br />', $debug) : '');
         $this->template[$this->director->theme->getConfig()->main_tag] = $template;
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('errorMessage', $e->getMessage(), false);
         $this->handleAdminUpdateGet();
     }
 }
Exemple #27
0
 /**
  * handle add
  */
 public function addComment($values)
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $values['active'] = 1;
     try {
         $id = $this->insert($values);
         $calendar = $this->plugin->getObject(Calendar::TYPE_DEFAULT);
         $calendarDetail = $calendar->getDetail(array('id' => $values['cal_id']));
         $url = new Url();
         $url->setPath($this->director->tree->getPath($calendarDetail['tree_id']));
         $url->setParameter('id', $calendarDetail['id']);
         $url->setParameter($view->getUrlId(), Calendar::VIEW_DETAIL);
         // notify insert
         $ip = $request->getValue('REMOTE_ADDR', Request::SERVER);
         $template = new TemplateEngine($this->getPath() . "templates/calendarcommentemail.tpl");
         $template->setVariable($values);
         $template->setVariable('calendarName', $calendarDetail['name']);
         $template->setVariable('href_detail', $url->getUrl());
         $template->setVariable('siteTitle', $this->director->tree->getTreeName());
         $template->setVariable('domain', $request->getDomain());
         $template->setVariable('protocol', $request->getProtocol());
         $template->setVariable('ip', $ip);
         $template->setVariable('host', gethostbyaddr($ip));
         $template->setVariable('client', $request->getValue('HTTP_USER_AGENT', Request::SERVER));
         $this->director->systemUser->notify($calendarDetail['tree_id'], 'Comment added at ' . $request->getDomain(), $template->fetch());
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('commentError', $e->getMessage(), false);
         $template->setVariable('cmtValues', $values, false);
     }
 }
Exemple #28
0
<h1>Dodaj auto</h1>
<a href="<?php 
echo Url::getUrl('marki', 'formMarki');
?>
"><button type="button">Dodaj markę</button></a>
<a href="<?php 
echo Url::getUrl('marki', 'list');
?>
"><button type="button">Lista marek</button></a>
<a href="<?php 
echo Url::getUrl('cars', 'list');
?>
"><button type="button">Lista samochodów</button></a>
<a href="<?php 
echo Url::getUrl('index', 'index');
?>
"><button type="button">Menu</button></a>

<form enctype="multipart/form-data" action="" method="post">
<select name="nazwaMarki">
    <?php 
if ($data) {
    foreach ($data as $wiersz) {
        echo "<option value='" . $wiersz['marki_id'] . "'>" . $wiersz['marki_nazwa'] . "</option>";
    }
}
?>
</select>
    <br/>
    <input type="text" name="nazwaAuta" placeholder="Nazwa auta"/>
    <br />
 /**
  * Verify invalid constructor parameters cause exceptions.
  *
  * @param mixed $type The text identifier for the URL.
  * @param mixed $url  The full URL (including scheme, domain, and path).
  *
  * @test
  * @dataProvider constructorGoodData
  *
  * @return void
  */
 public function constructWithValidParameters($type, $url)
 {
     $obj = new Url(['type' => $type, 'url' => $url]);
     $this->assertSame($type, $obj->getType());
     $this->assertSame($url, $obj->getUrl());
 }
Exemple #30
0
 public static function getPageContent(Url $url)
 {
     // Saving and clearing context
     $REAL = array();
     foreach ($GLOBALS as $key => $value) {
         if ($key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS') {
             $GLOBALS[$key] = array();
             $REAL[$key] = $value;
         }
     }
     // Saving and clearing session
     if (isset($_SESSION)) {
         $REAL_SESSION = array();
         foreach ($_SESSION as $key => $value) {
             $REAL_SESSION[$key] = $value;
             unset($_SESSION[$key]);
         }
     }
     // Running code in different context
     $scope = function () {
         extract(func_get_arg(1));
         $_GET = $_REQUEST = array("url" => $url->getUrl(), "max" => 5, "links" => "preserve", "exc" => "", "format" => "json", "submit" => "Create Feed");
         ob_start();
         require func_get_arg(0);
         $json = ob_get_contents();
         ob_end_clean();
         return $json;
     };
     $json = $scope("inc/3rdparty/makefulltextfeed.php", array("url" => $url));
     // Clearing and restoring context
     foreach ($GLOBALS as $key => $value) {
         if ($key != "GLOBALS" && $key != "_SESSION") {
             unset($GLOBALS[$key]);
         }
     }
     foreach ($REAL as $key => $value) {
         $GLOBALS[$key] = $value;
     }
     // Clearing and restoring session
     if (isset($REAL_SESSION)) {
         foreach ($_SESSION as $key => $value) {
             unset($_SESSION[$key]);
         }
         foreach ($REAL_SESSION as $key => $value) {
             $_SESSION[$key] = $value;
         }
     }
     return json_decode($json, true);
 }