Beispiel #1
0
 public function testFileUrls()
 {
     $testResult = 'file://' . getcwd();
     $url = Url::fromRequest();
     $this->assertEquals($testResult, $url->toString());
     $this->assertEquals(getcwd(), (string) $url);
     $url = Url::fromMagic($testResult);
     $this->assertEquals($testResult, $url->toString());
     $this->assertEquals(getcwd(), (string) $url);
 }
 /**
  * Parses a rudimentary system log backend page
  * @param \Cx\Core\Html\Sigma $template Backend template for this page
  * @param array $cmd Supplied CMD
  */
 public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
 {
     $em = $this->cx->getDb()->getEntityManager();
     $logRepo = $em->getRepository('Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log');
     // @todo: parse message if no entries (template block exists already)
     $parseObject = $this->getNamespace() . '\\Model\\Entity\\Log';
     // set default sorting
     if (!isset($_GET['order'])) {
         $_GET['order'] = 'timestamp/DESC';
     }
     // configure view
     $viewGenerator = new \Cx\Core\Html\Controller\ViewGenerator($parseObject, array('functions' => array('delete' => 'true', 'paging' => true, 'sorting' => true, 'edit' => true), 'fields' => array('id' => array('showOverview' => false), 'timestamp' => array('readonly' => true), 'severity' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
         return '<span class="' . contrexx_raw2xhtml(strtolower($data)) . '_background">' . contrexx_raw2xhtml($data) . '</span>';
     })), 'message' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
         $url = clone \Cx\Core\Routing\Url::fromRequest();
         $url->setMode('backend');
         $url->setParam('editid', $rows['id']);
         return '<a href="' . $url . '">' . contrexx_raw2xhtml($data) . '</a>';
     })), 'data' => array('readonly' => true, 'showOverview' => false, 'type' => 'text'), 'logger' => array('readonly' => true))));
     $template->setVariable('ENTITY_VIEW', $viewGenerator);
 }
 /**
  * This function returns the ViewGeneration options for a given entityClass
  *
  * @access protected
  * @global $_ARRAYLANG
  * @param $entityClassName contains the FQCN from entity
  * @return array with options
  */
 protected function getViewGeneratorOptions($entityClassName)
 {
     global $_ARRAYLANG;
     $classNameParts = explode('\\', $entityClassName);
     $classIdentifier = end($classNameParts);
     $langVarName = 'TXT_' . strtoupper($this->getType() . '_' . $this->getName() . '_ACT_' . $classIdentifier);
     $header = '';
     if (isset($_ARRAYLANG[$langVarName])) {
         $header = $_ARRAYLANG[$langVarName];
     }
     switch ($entityClassName) {
         case 'Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log':
             return array('functions' => array('delete' => 'true', 'paging' => true, 'sorting' => true, 'edit' => true), 'fields' => array('id' => array('showOverview' => false), 'timestamp' => array('readonly' => true), 'severity' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
                 return '<span class="' . contrexx_raw2xhtml(strtolower($data)) . '_background">' . contrexx_raw2xhtml($data) . '</span>';
             })), 'message' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
                 $url = clone \Cx\Core\Routing\Url::fromRequest();
                 $url->setMode('backend');
                 $url->setParam('editid', $rows['id']);
                 return '<a href="' . $url . '">' . contrexx_raw2xhtml($data) . '</a>';
             })), 'data' => array('readonly' => true, 'showOverview' => false, 'type' => 'text'), 'logger' => array('readonly' => true)));
             break;
         default:
             return array('header' => $header, 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false));
     }
 }
Beispiel #4
0
 /**
  * Initializes request
  */
 protected function postInit()
 {
     global $_CONFIG;
     // if path configuration was wrong in loadConfig(), Url is not yet initialized
     if (!$this->request) {
         // this makes \Env::get('Resolver')->getUrl() return a sensful result
         $request = !empty($_GET['__cap']) ? $_GET['__cap'] : '';
         $offset = $this->websiteOffsetPath;
         switch ($this->mode) {
             case self::MODE_FRONTEND:
             case self::MODE_BACKEND:
                 $this->request = new \Cx\Core\Routing\Model\Entity\Request($_SERVER['REQUEST_METHOD'], \Cx\Core\Routing\Url::fromCapturedRequest($request, $offset, $_GET));
                 break;
             case self::MODE_COMMAND:
             case self::MODE_MINIMAL:
                 try {
                     $this->request = new \Cx\Core\Routing\Model\Entity\Request($_SERVER['REQUEST_METHOD'], \Cx\Core\Routing\Url::fromRequest());
                 } catch (\Cx\Core\Routing\UrlException $e) {
                 }
                 break;
         }
     }
     //call post-init hooks
     $this->ch->callPostInitHooks();
 }