Example #1
0
function buildPage($key)
{
    global $dbPages;
    global $dbUsers;
    global $Parsedown;
    global $Site;
    // Page object, content from FILE.
    $Page = new Page($key);
    if (!$Page->isValid()) {
        Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying build the page from file with key: ' . $key);
        return false;
    }
    // Page database, content from DATABASE JSON.
    $db = $dbPages->getPageDB($key);
    if (!$db) {
        Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying build the page from database with key: ' . $key);
        return false;
    }
    // Foreach field from DATABASE.
    foreach ($db as $field => $value) {
        $Page->setField($field, $value);
    }
    // Content in raw format
    $contentRaw = $Page->content();
    $Page->setField('contentRaw', $Page->content(), true);
    // Parse markdown content.
    $content = Text::pre2htmlentities($contentRaw);
    // Parse pre code with htmlentities
    $content = $Parsedown->text($content);
    // Parse Markdown.
    $content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS);
    // Parse img src relative to absolute.
    $Page->setField('content', $content, true);
    // Pagebrake
    $explode = explode(PAGE_BREAK, $content);
    $Page->setField('breakContent', $explode[0], true);
    $Page->setField('readMore', !empty($explode[1]), true);
    // Date format
    $pageDate = $Page->date();
    $Page->setField('dateRaw', $pageDate, true);
    $pageDateFormated = $Page->dateRaw($Site->dateFormat());
    $Page->setField('date', $pageDateFormated, true);
    // User object
    $username = $Page->username();
    $Page->setField('user', $dbUsers->getUser($username));
    return $Page;
}
Example #2
0
function build_page($key)
{
    global $dbPages;
    global $dbUsers;
    global $Parsedown;
    global $Site;
    // Page object, content from FILE.
    $Page = new Page($key);
    if (!$Page->isValid()) {
        Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying build the page from file with key: ' . $key);
        return false;
    }
    // Page database, content from DATABASE JSON.
    $db = $dbPages->getDb($key);
    if (!$db) {
        Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying build the page from database with key: ' . $key);
        return false;
    }
    // Foreach field from DATABASE.
    foreach ($db as $field => $value) {
        $Page->setField($field, $value);
    }
    // Content in raw format
    $contentRaw = $Page->content();
    $Page->setField('contentRaw', $Page->content(), true);
    // Parse markdown content.
    $content = Text::pre2htmlentities($contentRaw);
    // Parse pre code with htmlentities
    $content = $Parsedown->text($content);
    // Parse Markdown.
    $content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS);
    // Parse img src relative to absolute.
    $Page->setField('content', $content, true);
    // Date format
    $pageDate = $Page->date();
    $Page->setField('dateRaw', $pageDate, true);
    $pageDateFormated = $Page->dateRaw($Site->dateFormat());
    $Page->setField('date', $pageDateFormated, true);
    // Parse username for the page.
    if ($dbUsers->userExists($Page->username())) {
        $user = $dbUsers->getDb($Page->username());
        $Page->setField('authorFirstName', $user['firstName'], false);
        $Page->setField('authorLastName', $user['lastName'], false);
    }
    return $Page;
}
Example #3
0
function build_page($key)
{
    global $dbPages;
    global $dbUsers;
    global $Parsedown;
    // Page object.
    $Page = new Page($key);
    if (!$Page->isValid()) {
        return false;
    }
    // Page database.
    $db = $dbPages->getDb($key);
    if (!$db) {
        return false;
    }
    // Foreach field from database.
    foreach ($db as $field => $value) {
        if ($field == 'unixTimeCreated') {
            // Format dates, not overwrite from file fields.
            $Page->setField('unixTimeCreated', $value, false);
            $Page->setField('date', Date::format($value, '%d %B'), false);
            $Page->setField('timeago', Date::timeago($value), false);
        } else {
            // Other fields, not overwrite from file fields.
            $Page->setField($field, $value, false);
        }
    }
    // Content in raw format
    $contentRaw = $Page->content();
    $Page->setField('contentRaw', $Page->content(), true);
    // Parse markdown content.
    $content = $Parsedown->text($contentRaw);
    // Parse Markdown.
    $content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS);
    // Parse img src relative to absolute.
    $Page->setField('content', $content, true);
    // Parse username for the page.
    if ($dbUsers->userExists($Page->username())) {
        $user = $dbUsers->getDb($Page->username());
        $Page->setField('authorFirstName', $user['firstName'], false);
        $Page->setField('authorLastName', $user['lastName'], false);
    }
    return $Page;
}
Example #4
0
 public function doGet(\Innomatic\Webapp\WebAppRequest $req, \Innomatic\Webapp\WebAppResponse $res)
 {
     // Start Innomatic
     $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     $innomatic->setInterface(\Innomatic\Core\InnomaticContainer::INTERFACE_EXTERNAL);
     $root = \Innomatic\Core\RootContainer::instance('\\Innomatic\\Core\\RootContainer');
     $innomatic_home = $root->getHome() . 'innomatic/';
     $innomatic->bootstrap($innomatic_home, $innomatic_home . 'core/conf/innomatic.ini');
     // Start Innomatic domain
     \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->startDomain(\Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getName());
     // Innomedia page
     $scope_page = 'frontend';
     // Check if the page exists in the page tree
     $pageSearch = PageTree::findPageByPath(substr($req->getPathInfo(), 1));
     if ($pageSearch === false) {
         // This is a static page (excluding the home page).
         $location = explode('/', $req->getPathInfo());
         $module_name = isset($location[1]) ? $location[1] : '';
         $page_name = isset($location[2]) ? $location[2] : '';
         $pageId = isset($location[3]) ? $location[3] : 0;
     } else {
         // This is the home page or a content page.
         $module_name = $pageSearch['module'];
         $page_name = $pageSearch['page'];
         $pageId = $pageSearch['page_id'];
     }
     // Define Innomatic context
     $home = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getHome();
     $context = Context::instance('\\Innomedia\\Context');
     $context->setRequest($req)->setResponse($res)->process();
     // Build Innomedia page
     $page = new Page($module_name, $page_name, $pageId, $scope_page);
     $page->parsePage();
     // Check if the page is valid
     if (!$page->isValid()) {
         $res->sendError(\Innomatic\Webapp\WebAppResponse::SC_NOT_FOUND, $req->getRequestURI());
     } else {
         $page->build();
     }
 }
Example #5
0
function build_page($key)
{
    global $dbPages;
    global $dbUsers;
    global $Parsedown;
    // Page object, content from FILE.
    $Page = new Page($key);
    if (!$Page->isValid()) {
        return false;
    }
    // Page database, content from DATABASE JSON.
    $db = $dbPages->getDb($key);
    if (!$db) {
        return false;
    }
    // Foreach field from DATABASE.
    foreach ($db as $field => $value) {
        $Page->setField($field, $value);
    }
    // Content in raw format
    $contentRaw = $Page->content();
    $Page->setField('contentRaw', $Page->content(), true);
    // Parse markdown content.
    $content = Text::pre2htmlentities($contentRaw);
    // Parse pre code with htmlentities
    $content = $Parsedown->text($content);
    // Parse Markdown.
    $content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS);
    // Parse img src relative to absolute.
    $Page->setField('content', $content, true);
    // Parse username for the page.
    if ($dbUsers->userExists($Page->username())) {
        $user = $dbUsers->getDb($Page->username());
        $Page->setField('authorFirstName', $user['firstName'], false);
        $Page->setField('authorLastName', $user['lastName'], false);
    }
    return $Page;
}
Example #6
0
 public function testSetAndGetKeyShouldProduceValidPage()
 {
     $page = new Page();
     $key = 'asdjknhskajsdbSSFDnsbdifbs';
     $page->setKey($key);
     $this->assertEquals($key, $page->getKey());
     $this->assertTrue($page->isValid());
 }
Example #7
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $page = Page::find($id);
     $rules = ['page' => 'required', 'html' => 'required', 'url_seo' => 'required'];
     if (!Page::isValid(Input::all(), $rules)) {
         return Redirect::back()->withInput()->withErrors(Page::$errors);
     }
     $page->page = Input::get('page');
     $page->html = Input::get('html');
     $page->url_seo = Input::get('url_seo');
     $page->activo = Input::get('activo');
     $page->mostrar_menu = Input::get('mostrar_menu');
     $page->save();
     return Redirect::to('/pages');
 }