/** * Edit a page * @param int $id * @throws \Exception */ public function edit_page($id = 0) { $this->to_tpl['success'] = false; $this->to_tpl['errors'] = false; $page = new Page(); if ($page = $page->getById($id)) { $this->to_tpl['page'] = $page; $this->template = "admin/edit-page"; if (isset($_POST['submit'])) { $errors = $this->check_input(); if (is_array($errors) && !empty($errors)) { $this->to_tpl['errors'] = $errors; } else { $page->title_sr = post_string('title_sr'); $page->body_sr = post_string('body_sr'); $page->title_en = post_string('title_en'); $page->body_en = post_string('body_en'); $page->permalink_sr = $page->check_permalink(generate_permalink($page->title_sr), "sr"); $page->permalink_en = $page->check_permalink(generate_permalink($page->title_en), "en"); $page->date_created = new \DateTime("now"); $page->published = post_bool('published'); if ($page->updateInDb()) { $this->to_tpl['success'] = true; } } } } else { header('Location: /admin/manage-pages'); } return; }
/** * Creates Standard URL for Pages * * Default function to create the correct url structure for each front-end pages * * @since 3.4 * @uses $PRETTYURLS * @uses $PERMALINK * @uses tsl * * @param string $slug * @param string $parent * @param string $absolute force absolute siteurl * @return string */ function generate_url($slug, $absolute = false) { global $PRETTYURLS; global $PERMALINK; // force slug to string in case a simpleXml object was passed ( from a page obj for example) $slug = (string) $slug; $delim = getDef('GSTOKENDELIM'); if (empty($slug)) { return; } // empty slug $path = tsl(getSiteURL($absolute)); $url = $path; // var to build url into if ($slug != getDef('GSINDEXSLUG')) { if ($PRETTYURLS == '1') { $url .= generate_permalink($slug); } else { if (!empty($PERMALINK)) { $url .= generate_permalink($slug, $PERMALINK); } else { $url .= 'index.php?id=' . $slug; } } } $url = exec_filter('generate_url', $url); // @filter generate_url (str) for generating urls after processing, for use with custom tokens etc return $url; }
function pageCacheAddRoutes($id, &$cacheItems) { global $pagesArray; if (!$pagesArray) { return false; } // add route $routesNode = $cacheItems->addChild('routes'); $routeNode = $routesNode->addChild('route'); // can lead to infinite loops $permaroute = no_tsl(generate_permalink($id)); $pathNode = $routeNode->addChild('path'); $pathNode->addCData($permaroute); $keyNode = $routeNode->addChild('key'); $keyNode->addCData(md5($permaroute)); }
/** * Name of the item * @param string $name */ public function get_menu_link($name = "") { $url = generate_permalink($name); $lang = static::$language; $current_page = static::$page_name; $class = check_current_menu($name, $current_page); echo "<a href=\"/{$lang}/{$url}\" class=\"{$class}\">{$name}</a>"; }
?> " href="#"><?php echo $service->get_language_title($lang); ?> </a> </li> <?php } ?> </ul> </section> <?php foreach ($services as $service) { ?> <article class="cell collapsable" data-value="<?php echo generate_permalink($service->get_language_title($lang)); ?> " style="display: none;"> <h1><?php echo $service->get_language_title($lang); ?> </h1> <div><?php echo $service->get_language_body($lang); ?> </div> </article> <?php } ?> </div>