Example #1
0
 function read($pagename)
 {
     global $Compat1x, $KeepToken;
     $page = parent::read($pagename);
     if ($page) {
         $page['text'] = preg_replace('/(\\[([=@]).*?\\2\\])/se', "Keep(PSS('\$1'))", @$page['text']);
         $page['text'] = preg_replace(array_keys($Compat1x), array_values($Compat1x), $page['text']);
         $page['text'] = preg_replace("/{$KeepToken}(\\d.*?){$KeepToken}/e", '$GLOBALS[\'KPV\'][\'$1\']', $page['text']);
     }
     return $page;
 }
Example #2
0
 function read($pagename)
 {
     global $Compat1x, $KeepToken;
     $page = parent::read($pagename);
     if ($page) {
         $page['text'] = preg_replace('/(\\[([=@]).*?\\2\\])/se', "Keep(PSS('\$1'))", @$page['text']);
         foreach ($Compat1x as $pat => $rep) {
             $page['text'] = preg_replace($pat, $rep, $page['text']);
         }
         $page['text'] = preg_replace("/{$KeepToken}(\\d.*?){$KeepToken}/e", '$GLOBALS[\'KPV\'][\'$1\']', $page['text']);
     }
     return $page;
 }
Example #3
0
 function write($pagename, $page)
 {
     global $EnablePageStoreXML;
     $EnablePageStoreXML == true ? $this->write_xml($pagename, $page) : parent::write($pagename, $page);
 }
Example #4
0
 public function url($id)
 {
     $page = $this->page($id);
     if (!$page) {
         return response::error(l('pages.error.missing'));
     }
     // avoid url changes for the home and error pages
     if ($page->isErrorPage() or $page->isHomePage()) {
         return response::error('This page type\'s url cannot be changed');
     }
     $changes = PageStore::fetch($page);
     PageStore::discard($page);
     try {
         if (site()->multilang() and site()->language()->code() != site()->defaultLanguage()->code()) {
             $page->update(array('URL-Key' => get('uid')));
         } else {
             $page->move(get('uid'));
         }
         PageStore::update($page, $changes);
         // hit the hook
         kirby()->trigger('panel.page.move', $page);
         return response::success('success', array('uid' => $page->uid(), 'uri' => $page->id()));
     } catch (Exception $e) {
         return response::error($e->getMessage());
     }
 }
Example #5
0
 public function show($id)
 {
     try {
         $page = $this->page($id);
     } catch (Exception $e) {
         $page = $this->page(dirname($id));
         // dirty work around to move to the parent page
         die('<script>window.location.href = "#/pages/show/' . $page->id() . '"</script>');
     }
     $blueprint = blueprint::find($page);
     $fields = $blueprint->fields($page);
     $content = $page->content()->toArray();
     $files = null;
     $subpages = null;
     $preview = null;
     // create the preview link
     if ($previewSetting = $blueprint->preview()) {
         switch ($previewSetting) {
             case 'parent':
                 $preview = $page->parent() ? $page->parent()->url() : $page->url();
                 break;
             case 'first-child':
                 $preview = $page->children()->first() ? $page->children()->first()->url() : false;
                 break;
             case 'last-child':
                 $preview = $page->children()->last() ? $page->children()->last()->url() : false;
                 break;
             default:
                 $preview = $page->url();
                 break;
         }
     }
     // make sure the title is always there
     $content['title'] = $page->title();
     // merge with the kept snapshot
     $changes = PageStore::fetch($page);
     $content = array_merge($content, $changes);
     // create the form
     $form = new Form($fields->toArray(), $content);
     // check for untranslatable fields
     if (site()->language() != site()->defaultLanguage()) {
         foreach ($form->fields() as $field) {
             if ($field->translate() == false) {
                 $field->readonly = true;
                 $field->disabled = true;
             }
         }
     }
     // create the subpages if they exist
     if ($blueprint->pages()->max() !== 0 and $blueprint->pages()->hide() == false) {
         // fetch all subpages in the right order
         $children = api::subpages($page->children(), $blueprint);
         // add pagination to the subpages
         if ($limit = $blueprint->pages()->limit()) {
             $children = $children->paginate($limit, array('page' => get('page')));
         }
         // create the snippet and fill it with all data
         $subpages = new Snippet('pages/sidebar/subpages', array('title' => l('pages.show.subpages.title'), 'page' => $page, 'subpages' => $children, 'addbutton' => !api::maxPages($page, $blueprint->pages()->max()), 'pagination' => $children->pagination()));
     }
     // create the files
     if ($blueprint->files()->max() !== 0 and $blueprint->files()->hide() == false) {
         $files = new Snippet('pages/sidebar/files', array('page' => $page, 'files' => api::files($page, $blueprint)));
     }
     // create the monster sidebar
     $sidebar = new Snippet('pages/sidebar', array('page' => $page, 'preview' => $preview, 'deletable' => !$page->hasChildren() and $page->isDeletable() and $blueprint->deletable(), 'subpages' => $subpages, 'files' => $files));
     return view('pages/show', array('topbar' => new Snippet('pages/topbar', array('breadcrumb' => new Snippet('pages/breadcrumb', array('page' => $page)), 'search' => purl($page, 'search'))), 'sidebar' => $sidebar, 'form' => $form, 'changes' => $changes, 'page' => $page, 'notitle' => !$form->fields()->get('title')));
 }