Esempio n. 1
0
 public static function outputContent($slug, $force = false)
 {
     $data = null;
     if ($force) {
         $file = GSDATAPAGESPATH . $slug . '.xml';
         if (file_exists($file)) {
             $data = getXML($file);
         }
     } else {
         $data = self::getPageData($slug);
     }
     if ($data) {
         $content = $data->content;
         $content = stripslashes(htmlspecialchars_decode($content, ENT_QUOTES));
         $content = exec_filter('content', $content);
         echo $content;
         return true;
     } else {
         return false;
     }
 }
/**
 * Get Main Navigation
 *
 * This will return unordered list of main navigation
 * This function uses the menu opitions listed within the 'Edit Page' control panel screen
 *
 * @since 1.0
 * @uses GSDATAOTHERPATH
 * @uses getXML
 * @uses subval_sort
 * @uses find_url
 * @uses strip_quotes 
 * @uses exec_filter 
 *
 * @param string $currentpage This is the ID of the current page the visitor is on
 * @param string $classPrefix Prefix that gets added to the parent and slug classnames
 * @return string 
 */
function get_navigation($currentpage = "", $classPrefix = "")
{
    $menu = '';
    global $pagesArray;
    $pagesSorted = subval_sort($pagesArray, 'menuOrder');
    if (count($pagesSorted) != 0) {
        foreach ($pagesSorted as $page) {
            $sel = $classes = '';
            $url_nav = (string) $page['url'];
            if ($page['menuStatus'] == 'Y') {
                $parentClass = !empty($page['parent']) ? $classPrefix . $page['parent'] . " " : "";
                $classes = trim($parentClass . $classPrefix . $url_nav);
                if ((string) $currentpage == $url_nav) {
                    $classes .= " current active";
                }
                if ($page['menu'] == '') {
                    $page['menu'] = $page['title'];
                }
                if ($page['title'] == '') {
                    $page['title'] = $page['menu'];
                }
                $menu .= '<li class="' . $classes . '"><a href="' . find_url($page['url'], $page['parent']) . '" title="' . encode_quotes(cl($page['title'])) . '">' . strip_decode($page['menu']) . '</a></li>' . "\n";
            }
        }
    }
    echo exec_filter('menuitems', $menu);
    // @filter menuitems (str) menu items html in get_navigation
}
Esempio n. 3
0
 public static function outputMenu($slug, $minlevel = 0, $maxlevel = 0, $show = I18N_SHOW_NORMAL, $component = null)
 {
     $slug = '' . $slug;
     $menu = self::getMenu($slug, $minlevel, $maxlevel, $show);
     if (isset($menu) && count($menu) > 0) {
         $html = self::getMenuHTML($menu, $show & I18N_OUTPUT_TITLE, $component);
         echo exec_filter('menuitems', $html);
     }
 }
Esempio n. 4
0
/**
 * Get Main Navigation
 *
 * This will return unordered list of main navigation
 * This function uses the menu opitions listed within the 'Edit Page' control panel screen
 *
 * @since 1.0
 * @uses GSDATAOTHERPATH
 * @uses getXML
 * @uses subval_sort
 * @uses find_url
 * @uses strip_quotes 
 * @uses exec_filter 
 *
 * @param string $currentpage This is the ID of the current page the visitor is on
 * @return string 
 */
function get_navigation($currentpage)
{
    $menu = '';
    global $pagesArray;
    $pagesSorted = subval_sort($pagesArray, 'menuOrder');
    if (count($pagesSorted) != 0) {
        foreach ($pagesSorted as $page) {
            $sel = '';
            $classes = '';
            $url_nav = $page['url'];
            if ($page['menuStatus'] == 'Y') {
                if ("{$currentpage}" == "{$url_nav}") {
                    $classes = "current active " . $page['parent'] . " " . $url_nav;
                } else {
                    $classes = trim($page['parent'] . " " . $url_nav);
                }
                if ($page['menu'] == '') {
                    $page['menu'] = $page['title'];
                }
                if ($page['title'] == '') {
                    $page['title'] = $page['menu'];
                }
                $menu .= '<li class="' . $classes . '"><a href="' . find_url($page['url'], $page['parent']) . '" title="' . encode_quotes(cl($page['title'])) . '">' . strip_decode($page['menu']) . '</a></li>' . "\n";
            }
        }
    }
    echo exec_filter('menuitems', $menu);
}
Esempio n. 5
0
function nm_ob_get_content($filter = true)
{
    $output = ob_get_contents();
    ob_end_clean();
    if ($filter) {
        return exec_filter('content', $output);
    } else {
        return $output;
    }
}
Esempio n. 6
0
/**
 * 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;
}
Esempio n. 7
0
function get_custom_field($name, $default = '')
{
    global $customfields;
    if (@$customfields[$name]) {
        $content = $customfields[$name];
        $types = i18n_customfield_types();
        if (@$types[$name] == 'textarea') {
            $content = exec_filter('content', $content);
        }
        echo $content;
        return true;
    } else {
        echo $default;
        return false;
    }
}
Esempio n. 8
0
} else {
    $id = "index";
}
// filter to modify page id request
$id = exec_filter('indexid', $id);
// $_GET['id'] = $id; // support for plugins that are checking get?
# define page, spit out 404 if it doesn't exist
$file_404 = GSDATAOTHERPATH . '404.xml';
$user_created_404 = GSDATAPAGESPATH . '404.xml';
$data_index = null;
// apply page data if page id exists
if (isset($pagesArray[$id])) {
    $data_index = getXml(GSDATAPAGESPATH . $id . '.xml');
}
// filter to modify data_index obj
$data_index = exec_filter('data_index', $data_index);
// page not found handling
if (!$data_index) {
    if (isset($pagesArray['404'])) {
        // use user created 404 page
        $data_index = getXml($user_created_404);
    } elseif (file_exists($file_404)) {
        // default 404
        $data_index = getXml($file_404);
    } else {
        // fail over
        redirect('404');
    }
    exec_action('error-404');
}
$title = $data_index->title;
Esempio n. 9
0
         delete_page($oldslug);
         // backup and delete the page
     }
     exec_action('changedata-save');
     // @hook changedata-save prior to saving a page
     $xml = exec_filter('pagesavexml', $xml);
     // @filter pagesavexml (obj) xml object of a page save
     savePageXml($xml);
     exec_action('changedata-aftersave');
     // @hook changedata-aftersave after a page was saved
     // genen sitemap if published save
     generate_sitemap();
 } else {
     exec_action('changedata-save-draft');
     // @hook changedata-save-draft saving a draft page
     $xml = exec_filter('draftsavexml', $xml);
     // @filter draftsavexml (obj) xml object of a page draft save
     saveDraftXml($xml);
     exec_action('changedata-aftersave-draft');
     // @hook changedata-aftersave-draft after draft was saved
 }
 /**
  * do changedata ajax save checking for legacy
  * @param  str $url     [description]
  * @param  str $oldslug [description]
  */
 function changedataAjaxSave($url, $oldslug)
 {
     global $draft, $pageIsNew;
     if (isset($_POST['ajaxsave'])) {
         // force redirects
Esempio n. 10
0
function nm_custom_display_posts($templ = '', $tag = '', $type = '')
{
    global $NMRECENTPOSTS, $NMCUSTOMIMAGES, $NMCUSTOMOFFSET;
    if ($templ == '') {
        $templ = '<p><a href="{{ post_link }}">{{ post_title }}</a> {{ post_date }}</p>' . PHP_EOL;
    }
    foreach (array('post_link', 'post_slug', 'post_title', 'post_date', 'post_excerpt', 'post_content', 'post_number', 'post_image', 'post_image_url', 'post_author') as $token) {
        if (strpos($templ, '{{' . $token . '}}')) {
            $templ = str_replace('{{' . $token . '}}', '{{ ' . $token . ' }}', $templ);
        }
    }
    if ($type == 'future') {
        $posts = array_reverse(nm_get_posts(true));
        $allposts = array();
        $now = time();
        foreach ($posts as $post) {
            if ($post->private != 'Y' && strtotime($post->date) > $now) {
                $allposts[] = $post;
            }
        }
    } else {
        $allposts = nm_get_posts();
    }
    if (trim($tag) !== '') {
        $posts = array();
        foreach ($allposts as $post) {
            if (in_array($tag, explode(',', $post->tags))) {
                $posts[] = $post;
            }
        }
    } else {
        $posts = $allposts;
    }
    unset($allposts);
    if (!empty($posts)) {
        ob_start();
        // content filter
        if (strpos($templ, '{{ post_date }}') !== false) {
            global $NMCUSTOMDATE;
            $fmt = $NMCUSTOMDATE ? $NMCUSTOMDATE : i18n_r('news_manager/DATE_FORMAT');
        } else {
            $fmt = false;
        }
        $w = isset($NMCUSTOMIMAGES['width']) ? $NMCUSTOMIMAGES['width'] : 0;
        $h = isset($NMCUSTOMIMAGES['height']) ? $NMCUSTOMIMAGES['height'] : 0;
        $c = isset($NMCUSTOMIMAGES['crop']) ? $NMCUSTOMIMAGES['crop'] : 0;
        $d = isset($NMCUSTOMIMAGES['default']) ? $NMCUSTOMIMAGES['default'] : '';
        $count = 0;
        $offset = $NMCUSTOMOFFSET ? intval($NMCUSTOMOFFSET) : 0;
        $posts = array_slice($posts, $offset, $NMRECENTPOSTS, true);
        foreach ($posts as $post) {
            $str = $templ;
            $str = str_replace('{{ post_number }}', strval($count), $str);
            $str = str_replace('{{ post_slug }}', $post->slug, $str);
            $str = str_replace('{{ post_link }}', nm_get_url('post') . $post->slug, $str);
            $str = str_replace('{{ post_title }}', stripslashes($post->title), $str);
            if (strpos($str, '{{ post_image') !== false && function_exists('nm_get_image_url')) {
                $img = htmlspecialchars(nm_get_image_url((string) $post->image, $w, $h, $c, $d));
                $str = str_replace('{{ post_image_url }}', $img, $str);
                if (!empty($img)) {
                    $str = str_replace('{{ post_image }}', '<img src="' . $img . '" alt="" />', $str);
                } else {
                    $str = str_replace('{{ post_image }}', '', $str);
                }
            }
            if ($fmt) {
                $date = nm_get_date($fmt, strtotime($post->date));
                $str = str_replace('{{ post_date }}', $date, $str);
            }
            if (strpos($str, '{{ post_author }}') !== false) {
                if (isset($post->author)) {
                    $author = strval($post->author);
                    global $NMAUTHOR;
                    // NM Custom Authors (array)
                    if ($NMAUTHOR && isset($NMAUTHOR[$author])) {
                        $author = $NMAUTHOR[$author];
                    }
                } else {
                    if (function_exists('nm_get_option')) {
                        $author = nm_get_option('defaultauthor');
                        // NM 3.0+ custom setting
                        if (!$author) {
                            $author = '';
                        }
                    } else {
                        $author = '';
                    }
                }
                $str = str_replace('{{ post_author }}', $author, $str);
            }
            if (strpos($str, '{{ post_excerpt }}') !== false || strpos($str, '{{ post_content }}') !== false) {
                $postxml = getXML(NMPOSTPATH . $post->slug . '.xml');
                if (strpos($str, '{{ post_excerpt }}') !== false) {
                    if (function_exists('nm_make_excerpt1')) {
                        $excerpt = nm_make_excerpt(strip_decode($postxml->content));
                    } else {
                        // NM < 3.0 - remove <p>, </p>
                        $excerpt = substr(nm_create_excerpt(strip_decode($postxml->content)), 3, -4);
                    }
                    $str = str_replace('{{ post_excerpt }}', $excerpt, $str);
                } else {
                    $str = str_replace('{{ post_content }}', strip_decode($postxml->content), $str);
                }
            }
            echo $str;
            $count++;
        }
        $output = ob_get_contents();
        ob_end_clean();
        echo exec_filter('content', $output);
        // content filter
    }
}
/**
 * Creates Sitemap
 *
 * Creates sitemap.xml in the site's root.
 */
function generate_sitemap()
{
    if (getDef('GSNOSITEMAP', true)) {
        return;
    }
    // Variable settings
    global $SITEURL;
    $path = GSDATAPAGESPATH;
    global $pagesArray;
    getPagesXmlValues(false);
    $pagesSorted = subval_sort($pagesArray, 'menuStatus');
    if (count($pagesSorted) != 0) {
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
        $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
        $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
        foreach ($pagesSorted as $page) {
            if ($page['url'] != '404') {
                if ($page['private'] != 'Y') {
                    // set <loc>
                    $pageLoc = find_url($page['url'], $page['parent']);
                    // set <lastmod>
                    $tmpDate = date("Y-m-d H:i:s", strtotime($page['pubDate']));
                    $pageLastMod = makeIso8601TimeStamp($tmpDate);
                    // set <changefreq>
                    $pageChangeFreq = 'weekly';
                    // set <priority>
                    if ($page['menuStatus'] == 'Y') {
                        $pagePriority = '1.0';
                    } else {
                        $pagePriority = '0.5';
                    }
                    //add to sitemap
                    $url_item = $xml->addChild('url');
                    $url_item->addChild('loc', $pageLoc);
                    $url_item->addChild('lastmod', $pageLastMod);
                    $url_item->addChild('changefreq', $pageChangeFreq);
                    $url_item->addChild('priority', $pagePriority);
                }
            }
        }
        //create xml file
        $file = GSROOTPATH . 'sitemap.xml';
        $xml = exec_filter('sitemap', $xml);
        XMLsave($xml, $file);
        exec_action('sitemap-aftersave');
    }
    if (!defined('GSDONOTPING')) {
        if (file_exists(GSROOTPATH . 'sitemap.xml')) {
            if (200 === ($status = pingGoogleSitemaps($SITEURL . 'sitemap.xml'))) {
                #sitemap successfully created & pinged
                return true;
            } else {
                error_log(i18n_r('SITEMAP_ERRORPING'));
                return i18n_r('SITEMAP_ERRORPING');
            }
        } else {
            error_log(i18n_r('SITEMAP_ERROR'));
            return i18n_r('SITEMAP_ERROR');
        }
    } else {
        #sitemap successfully created - did not ping
        return true;
    }
}
Esempio n. 12
0
/**
 * Get Main Navigation
 *
 * This will return unordered list of main navigation
 * This function uses the menu opitions listed within the 'Edit Page' control panel screen
 *
 * @since 1.0
 * @uses GSDATAOTHERPATH
 * @uses getXML
 * @uses subval_sort
 * @uses find_url
 * @uses strip_quotes 
 * @uses exec_filter 
 *
 * @param string $currentpage This is the ID of the current page the visitor is on
 * @return string 
 */
function get_navigation($currentpage)
{
    $menu = '';
    $path = GSDATAPAGESPATH;
    $dir_handle = opendir($path) or die("Unable to open {$path}");
    $filenames = array();
    while ($filename = readdir($dir_handle)) {
        $filenames[] = $filename;
    }
    $count = "0";
    $pagesArray = array();
    if (count($filenames) != 0) {
        foreach ($filenames as $file) {
            if ($file == "." || $file == ".." || is_dir($path . $file) || $file == ".htaccess") {
                // not a page data file
            } else {
                $data = getXML($path . $file);
                if ($data->private != 'Y') {
                    $pagesArray[$count]['menuStatus'] = $data->menuStatus;
                    $pagesArray[$count]['menuOrder'] = $data->menuOrder;
                    $pagesArray[$count]['menu'] = strip_decode($data->menu);
                    $pagesArray[$count]['url'] = $data->url;
                    $pagesArray[$count]['title'] = strip_decode($data->title);
                    $pagesArray[$count]['parent'] = $data->parent;
                    $count++;
                }
            }
        }
    }
    $pagesSorted = subval_sort($pagesArray, 'menuOrder');
    if (count($pagesSorted) != 0) {
        foreach ($pagesSorted as $page) {
            $sel = '';
            $classes = '';
            $url_nav = $page['url'];
            if ($page['menuStatus'] == 'Y') {
                if ("{$currentpage}" == "{$url_nav}") {
                    $classes = "current " . $page['parent'] . " " . $url_nav;
                } else {
                    $classes = trim($page['parent'] . " " . $url_nav);
                }
                if ($page['menu'] == '') {
                    $page['menu'] = $page['title'];
                }
                if ($page['title'] == '') {
                    $page['title'] = $page['menu'];
                }
                $menu .= '<li class="' . $classes . '"><a href="' . find_url($page['url'], $page['parent']) . '" title="' . strip_quotes($page['title']) . '">' . $page['menu'] . '</a></li>' . "\n";
            }
        }
    }
    closedir($dir_handle);
    echo exec_filter('menuitems', $menu);
}
/**
 * Save pagecache xml file
 * @param  simpleXmlObj
 * @return sucess
 */
function save_pageCacheXml($xml)
{
    // debugLog(debug_backtrace());
    $file = GSDATAOTHERPATH . getDef('GSPAGECACHEFILE');
    // Plugin Authors should add custome fields etc.. here
    $xml = exec_filter('pagecache', $xml);
    // @filter pagecache (obj) filter the page cache xml obj before save
    if (!empty($xml)) {
        XMLsave($xml, $file);
    }
    exec_action('pagecache-aftersave');
    // @hook pagecache-aftersave pagecache data file was saved
    debugLog("page cache: saved");
    return;
}
Esempio n. 14
0
/**
 * Get Main Navigation
 *
 * This will return unordered list of main navigation
 * This function uses the menu opitions listed within the 'Edit Page' control panel screen
 *
 * @since 1.0
 * @uses GSDATAOTHERPATH
 * @uses getXML
 * @uses subval_sort
 * @uses find_url
 * @uses strip_quotes 
 * @uses exec_filter 
 *
 * @param string $currentpage This is the ID of the current page the visitor is on
 * @param string $classPrefix Prefix that gets added to the parent and slug classnames
 * @return string 
 */
function get_navigation($currentpage, $classPrefix = "")
{
    $menu = '';
    global $pagesArray;
    global $SITEURL;
    // Kevin F - Just initializing array and img tag outside the loops
    $imgExts = array('.png', '.jpg', '.gif');
    $imgTag = '';
    $pagesSorted = subval_sort($pagesArray, 'menuOrder');
    if (count($pagesSorted) != 0) {
        foreach ($pagesSorted as $page) {
            $sel = '';
            $classes = '';
            $url_nav = $page['url'];
            // Kevin F - Change the $icon variable to suit your directory needs
            foreach ($imgExts as $ext) {
                if (is_file(GSDATAUPLOADPATH . 'img/menu-icons/' . $page['url'] . $ext)) {
                    $icon = $SITEURL . 'data/uploads/img/menu-icons/' . $page['url'] . $ext;
                    $imgTag = '<img src="' . $icon . '" alt="' . $page['title'] . ' " width="65" height="65">';
                    break;
                    // File found! break out of loop...
                } else {
                    $imgTag = '';
                    // Add no img element as there is no image...
                }
            }
            if ($page['menuStatus'] == 'Y') {
                $parentClass = !empty($page['parent']) ? $classPrefix . $page['parent'] . " " : "";
                $classes = trim($parentClass . $classPrefix . $url_nav);
                if ("{$currentpage}" == "{$url_nav}") {
                    $classes .= " current active";
                }
                if ($page['menu'] == '') {
                    $page['menu'] = $page['title'];
                }
                if ($page['title'] == '') {
                    $page['title'] = $page['menu'];
                }
                // Kevin F - The menu variable below has been modified to cater for icons and alt name
                $menu .= '<li class="' . $classes . '"><a href="' . find_url($page['url'], $page['parent']) . '" title="' . encode_quotes(cl($page['title'])) . '">' . $imgTag . '<span class="link-title">' . strip_decode($page['menu']) . '</span></a></li>' . "\n";
            }
        }
    }
    echo exec_filter('menuitems', $menu);
}
Esempio n. 15
0
/**
 * Return Page Content
 *
 * Return the content of the requested page. 
 * As the Content is not cahed the file is read in.
 *
 * @since 3.1
 * @param $page - slug of the page to retrieve content
 *
 */
function returnPageContent($page, $field = 'content')
{
    $thisfile = file_get_contents(GSDATAPAGESPATH . $page . '.xml');
    $data = simplexml_load_string($thisfile);
    $content = stripslashes(htmlspecialchars_decode($data->{$field}, ENT_QUOTES));
    if ($field == 'content') {
        $content = exec_filter('content', $content);
    }
    return $content;
}
Esempio n. 16
0
/**
 * Creates Sitemap
 *
 * Creates GSSITEMAPFILE (sitemap.xml) in the site's root.
 */
function generate_sitemap()
{
    if (getDef('GSNOSITEMAP', true)) {
        return;
    }
    global $pagesArray;
    // Variable settings
    $SITEURL = getSiteURL(true);
    $path = GSDATAPAGESPATH;
    getPagesXmlValues(false);
    $pagesSorted = subval_sort($pagesArray, 'menuStatus');
    if (count($pagesSorted) > 0) {
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
        $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
        $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
        foreach ($pagesSorted as $page) {
            if ($page['url'] != '404') {
                if ($page['private'] != 'Y') {
                    // set <loc>
                    $pageLoc = find_url($page['url'], $page['parent'], 'full');
                    // set <lastmod>
                    $tmpDate = date("Y-m-d H:i:s", strtotime($page['pubDate']));
                    $pageLastMod = makeIso8601TimeStamp($tmpDate);
                    // set <changefreq>
                    $pageChangeFreq = 'weekly';
                    // set <priority>
                    if ($page['menuStatus'] == 'Y') {
                        $pagePriority = '1.0';
                    } else {
                        $pagePriority = '0.5';
                    }
                    //add to sitemap
                    $url_item = $xml->addChild('url');
                    $url_item->addChild('loc', $pageLoc);
                    $url_item->addChild('lastmod', $pageLastMod);
                    $url_item->addChild('changefreq', $pageChangeFreq);
                    $url_item->addChild('priority', $pagePriority);
                }
            }
        }
        //create xml file
        $file = GSROOTPATH . GSSITEMAPFILE;
        $xml = exec_filter('sitemap', $xml);
        // @filter sitemap (obj) filter the sitemap $xml obj
        $status = XMLsave($xml, $file);
        exec_action('sitemap-aftersave');
        // @hook sitemap-aftersave after a sitemap data file was saved
        #sitemap successfully created
        return $status;
    } else {
        return true;
    }
}
Esempio n. 17
0
/**
 * Create the Cached Pages XML file
 *
 * Reads in each page of the site and creates a single XML file called 
 * data/pages/pages.array 
 *
 * @since 3.1
 *  
 */
function create_pagesxml($flag)
{
    global $pagesArray;
    $success = '';
    // debugLog("create_pagesxml: " . $flag);
    if (isset($_GET['upd']) && $_GET['upd'] == "edit-success" || $flag === true || $flag == 'true') {
        $pagesArray = array();
        // debugLog("create_pagesxml proceeding");
        $menu = '';
        $filem = GSDATAOTHERPATH . "pages.xml";
        $path = GSDATAPAGESPATH;
        $dir_handle = @opendir($path) or die("create_pagesxml: Unable to open {$path}");
        $filenames = array();
        while ($filename = readdir($dir_handle)) {
            $ext = substr($filename, strrpos($filename, '.') + 1);
            if ($ext == "xml") {
                $filenames[] = $filename;
            }
        }
        $count = 0;
        $xml = @new SimpleXMLExtended('<channel></channel>');
        if (count($filenames) != 0) {
            foreach ($filenames as $file) {
                if ($file == "." || $file == ".." || is_dir(GSDATAPAGESPATH . $file) || $file == ".htaccess") {
                    // not a page data file
                } else {
                    $thisfile = file_get_contents($path . $file);
                    $data = simplexml_load_string($thisfile);
                    if (!$data) {
                        // handle corrupt page xml
                        debugLog("page {$file} is corrupt");
                        continue;
                    }
                    $count++;
                    $id = $data->url;
                    $pages = $xml->addChild('item');
                    // $pages->addChild('url', $id);
                    // $pagesArray[(string)$id]['url']=(string)$id;
                    foreach ($data->children() as $item => $itemdata) {
                        if ($item != "content") {
                            $note = $pages->addChild($item);
                            $note->addCData($itemdata);
                            $pagesArray[(string) $id][$item] = (string) $itemdata;
                        }
                    }
                    $note = $pages->addChild('slug');
                    $note->addCData($id);
                    $pagesArray[(string) $id]['slug'] = (string) $id;
                    $pagesArray[(string) $id]['filename'] = $file;
                    $note = $pages->addChild('filename');
                    $note->addCData($file);
                }
                // else
            }
            // end foreach
        }
        // endif
        if ($flag === true || $flag == 'true') {
            // Plugin Authors should add custom fields etc.. here
            $xml = exec_filter('pagecache', $xml);
            // sanity check in case the filter does not come back properly or returns null
            if ($xml) {
                $success = $xml->asXML($filem);
            }
            // debugLog("create_pagesxml saved: ". $success);
            exec_action('pagecache-aftersave');
            return $success;
        }
    }
}
Esempio n. 18
0
/**
 * XML Save
 *
 * @since 2.0
 * @todo create and chmod file before ->asXML call (if it doesnt exist already, if so, then just chmod it.)
 *
 * @param object $xml
 * @param string $file Filename that it will be saved as
 * @return bool
 */
function XMLsave($xml, $file)
{
    # get_execution_time(true);
    if (!is_object($xml)) {
        debugLog(__FUNCTION__ . ' failed to save xml');
        return false;
    }
    $data = @$xml->asXML();
    if (getDef('GSFORMATXML', true)) {
        $data = formatXmlString($data);
    }
    // format xml if config setting says so
    $data = exec_filter('xmlsave', $data);
    // @filter xmlsave executed before writing string to file
    $success = file_put_contents($file, $data);
    // LOCK_EX ?
    // debugLog('XMLsave: ' . $file . ' ' . get_execution_time());
    if (getDef('GSDOCHMOD') === false) {
        return $success;
    }
    if (defined('GSCHMOD')) {
        return $success && chmod($file, GSCHMOD);
    } else {
        return $success && chmod($file, 0755);
    }
}
Esempio n. 19
0
/**
 * Save pagecache xml file
 * @param  simpleXmlObj
 * @return sucess
 */
function save_pageCacheXml($xml)
{
    $file = GSDATAOTHERPATH . "pages.xml";
    // Plugin Authors should add custome fields etc.. here
    $xml = exec_filter('pagecache', $xml);
    if (!empty($xml)) {
        $success = $xml->asXML($file);
    }
    exec_action('pagecache-aftersave');
    return;
}
Esempio n. 20
0
$setlang = isset($_GET["setlang"]);
$result = array();
if ($page == "" || $page == "init" || $setlang) {
    if (!$setlang) {
        $page = "index";
    }
    $result["langs"] = return_i18n_languages();
    $result["tabs"] = return_i18n_menu_data(return_page_slug(), 0, 0, I18N_SHOW_MENU);
    //echo $other_lang;
}
$content = "";
$title = "";
$url = $page;
if (isset($pagesArray[$page])) {
    $data_index = return_i18n_page_data($page);
    $content = strip_decode($data_index->content);
    $content = exec_filter('content', $content);
    $title = strip_decode($data_index->title);
    $url = strip_decode($data_index->url);
}
$page_content = array();
$children = return_i18n_menu_data($page, 1, 1, I18N_SHOW_MENU);
if (!is_null($children)) {
    $page_content["children"] = $children;
}
$page_content["title"] = $title;
$page_content["content"] = $content;
$result["url"] = $url;
$result["page"] = $page_content;
//$result["content"] = get_content($page);
echo json_encode($result);