Author: Fred Delaunay (fred@nemako.net)
Esempio n. 1
0
/**
 * Automatically activate all core themes in the "themes" directory.
 */
function activate_core_themes()
{
    include_once PHPWG_ROOT_PATH . 'admin/include/themes.class.php';
    $themes = new themes();
    foreach ($themes->fs_themes as $theme_id => $fs_theme) {
        if (in_array($theme_id, array('elegant', 'smartpocket'))) {
            $themes->perform_action('activate', $theme_id);
        }
    }
}
Esempio n. 2
0
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#handleForm($form)
  */
 public function handleForm($form)
 {
     if ($form->exportValue('remote_theme')) {
         $file = $form->exportValue('remote_theme');
         if (!fopen($file, 'r')) {
             throw new EfrontFileException(_FILEDOESNOTEXIST . ': ' . $file, EfrontFileException::FILE_NOT_EXIST);
         }
     } else {
         try {
             $filesystem = new FileSystemTree(G_THEMESPATH, true);
             $themeFile = $filesystem->uploadFile('theme_file', G_THEMESPATH);
             $filesList = $themeFile->listContents();
             if (mb_substr($filesList[0], 0, mb_strpos($filesList[0], "/")) == "default") {
                 throw new Exception(_DEFAULTTHEMECANNOTBEIMPORTED, EfrontThemesException::DEFAULT_IMPORTED);
             }
             $themeFile->uncompress(false);
             //$pathInfo = pathinfo($themeFile['path']);
             //copy(G_DEFAULTTHEMEPATH.'css/css_global.php', $pathInfo['dirname'].'/'.$pathInfo['filename'].'/css/css_global.php');
             $themeFile->delete();
             $file = new EfrontFile($themeFile['directory'] . '/' . str_replace('.zip', '', $themeFile['name']) . "/theme.xml");
         } catch (EfrontFileException $e) {
             //Don't halt if no file was uploaded (errcode = 4). Otherwise, throw the exception
             if ($e->getCode() != 4) {
                 throw $e;
             }
         }
     }
     if ($file) {
         $xmlValues = themes::parseFile($file);
         if ($_GET['add']) {
             $theme = self::create($xmlValues);
         }
         /*
         else {
             $this -> options = array_merge($this -> options, $xmlValues);
             $this -> layout  =
             $this -> persist();
         }
         */
     }
     //$smarty -> assign("T_RELOAD_ALL", 1);
 }
Esempio n. 3
0
<?php

require 'controllers/system.controller.php';
$uri = $_SERVER['REQUEST_URI'];
$path = explode('/', $uri);
$db = new system_model();
$system = new system($db->database);
array_shift($path);
if ($uri == '/') {
    require 'controllers/themes.controller.php';
    $class = new themes($db->database);
    $class->main();
} elseif (file_exists('controllers/' . $path[0] . '.controller.php')) {
    include 'controllers/' . $path[0] . '.controller.php';
    $class_name = $path[0];
    $class = new $class_name();
    $method = $path[1];
    unset($path[0]);
    unset($path[1]);
    $path = array_values($path);
    if (isset($method) and !is_numeric($method)) {
        call_user_func_array(array($class, $method), $path);
    } else {
        $class->main($method);
    }
} else {
    echo '404';
}
Esempio n. 4
0
        } catch (Exception $e) {
            handleAjaxExceptions($e);
        }
        exit;
    }
    if (isset($_GET['reset_theme']) && $_GET['reset_theme'] == $currentSetTheme->{$currentSetTheme->entity}['id']) {
        try {
            $currentSetTheme->applySettings();
        } catch (Exception $e) {
            handleAjaxExceptions($e);
        }
        exit;
    }
    if (isset($_GET['export_theme']) && in_array($_GET['export_theme'], $legalValues) && eF_checkParameter($_GET['export_theme'], 'id')) {
        try {
            $theme = new themes($_GET['export_theme']);
            if ($theme->options['locked']) {
                throw new EfrontThemesException(_THEMELOCKED, EfrontThemesException::THEME_LOCKED);
            }
            $file = $theme->export();
            echo $file['path'];
            //$theme -> applySettings();
            //EfrontConfiguration::setValue('theme', $_GET['set_theme']);
        } catch (Exception $e) {
            handleAjaxExceptions($e);
        }
        exit;
    }
} catch (Exception $e) {
    handleNormalFlowExceptions($e);
}
Esempio n. 5
0
function xs_install_style($tpl, $num)
{
    global $db;
    $data = xs_get_themeinfo($tpl);
    if (empty($data[$num])) {
        return false;
    }
    $data = $data[$num];
    if (empty($data['style_name'])) {
        return false;
    }
    $sql = "SELECT themes_id FROM " . THEMES_TABLE . " WHERE style_name='" . xs_sql($data['style_name']) . "'";
    if (!($result = $db->sql_query($sql))) {
        return false;
    }
    $row = $db->sql_fetchrow($result);
    if (!empty($row['themes_id'])) {
        return false;
    }
    $vars = array();
    $values = array();
    foreach ($data as $var => $value) {
        $vars[] = xs_sql($var);
        $values[] = xs_sql(stripslashes($value));
    }
    $sql = "INSERT INTO " . THEMES_TABLE . " (" . implode(', ', $vars) . ") VALUES ('" . implode("', '", $values) . "')";
    if (!($result = $db->sql_query($sql))) {
        return false;
    }
    // recache themes table
    if (defined('XS_MODS_CATEGORY_HIERARCHY210')) {
        global $themes;
        if (empty($themes)) {
            $themes = new themes();
        }
        if (!empty($themes)) {
            $themes->read(true);
        }
    }
    // add configuration
    global $template;
    if ($template->add_config($tpl)) {
        define('REFRESH_NAVBAR', true);
    }
    return true;
}
Esempio n. 6
0
// | This program is distributed in the hope that it will be useful, but   |
// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
// | General Public License for more details.                              |
// |                                                                       |
// | You should have received a copy of the GNU General Public License     |
// | along with this program; if not, write to the Free Software           |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA.                                                                  |
// +-----------------------------------------------------------------------+
if (!defined("PHPWG_ROOT_PATH")) {
    die("Hacking attempt!");
}
include_once PHPWG_ROOT_PATH . 'admin/include/themes.class.php';
$base_url = get_root_url() . 'admin.php?page=' . $page['page'];
$themes = new themes();
// +-----------------------------------------------------------------------+
// |                          perform actions                              |
// +-----------------------------------------------------------------------+
if (isset($_GET['action']) and isset($_GET['theme'])) {
    $page['errors'] = $themes->perform_action($_GET['action'], $_GET['theme']);
    if (empty($page['errors'])) {
        if ($_GET['action'] == 'activate' or $_GET['action'] == 'deactivate') {
            $template->delete_compiled_templates();
        }
        redirect($base_url);
    }
}
// +-----------------------------------------------------------------------+
// |                     start template output                             |
// +-----------------------------------------------------------------------+
Esempio n. 7
0
    }
    // remove config
    if (empty($HTTP_GET_VARS['nocfg']) && isset($board_config['xs_style_' . $row['template_name']])) {
        $sql = "DELETE FROM " . CONFIG_TABLE . " WHERE config_name='" . addslashes("xs_style_{$row['template_name']}") . "'";
        $db->sql_query($sql);
        $template->assign_block_vars('left_refresh', array('ACTION' => append_sid('index.' . $phpEx . '?pane=left')));
        // recache config table for cat_hierarchy 2.1.0
        if (isset($GLOBALS['config']) && is_object($GLOBALS['config'])) {
            global $config;
            $config->read(true);
        }
    }
    // recache themes table
    if (defined('XS_MODS_CATEGORY_HIERARCHY210')) {
        if (empty($themes)) {
            $themes = new themes();
        }
        if (!empty($themes)) {
            $themes->read(true);
        }
    }
}
function remove_all($dir)
{
    $res = opendir($dir);
    if (!$res) {
        return false;
    }
    while (($file = readdir($res)) !== false) {
        if ($file !== '.' && $file !== '..') {
            $str = $dir . '/' . $file;
/**
 * Setup themes
 *
 * This function sets up all the required constants and initiates objects
 * accordingly, to initialize the current theme
 *
 * @since 3.6.0
 */
function setupThemes()
{
    /** The default theme path*/
    define("G_DEFAULTTHEMEPATH", G_THEMESPATH . "default/");
    /** The default theme url*/
    define("G_DEFAULTTHEMEURL", "themes/default/");
    try {
        $allThemes = themes::getAll();
        if (isset($_GET['preview_theme'])) {
            try {
                $currentTheme = new themes($_GET['preview_theme']);
            } catch (Exception $e) {
            }
        } elseif (isset($_SESSION['s_theme'])) {
            if (!empty($allThemes[$_SESSION['s_theme']])) {
                $currentTheme = $allThemes[$_SESSION['s_theme']];
            } else {
                $currentTheme = new themes($_SESSION['s_theme']);
            }
        } else {
            if (!empty($allThemes[$GLOBALS['configuration']['theme']])) {
                $currentTheme = $allThemes[$GLOBALS['configuration']['theme']];
            } else {
                $currentTheme = new themes($GLOBALS['configuration']['theme']);
            }
            $browser = detectBrowser();
            foreach ($allThemes as $value) {
                if (isset($value->options['browsers'][$browser])) {
                    try {
                        $browserTheme = $allThemes[$value->themes['id']];
                        $currentTheme = $browserTheme;
                    } catch (Exception $e) {
                    }
                }
            }
            foreach (eF_loadAllModules(true, true) as $module) {
                try {
                    if ($moduleTheme = $module->onSetTheme($currentTheme)) {
                        if (!$moduleTheme instanceof themes) {
                            $currentTheme = new themes($moduleTheme);
                        } else {
                            $currentTheme = $moduleTheme;
                        }
                    }
                } catch (Exception $e) {
                }
            }
            $_SESSION['s_theme'] = $currentTheme->{$currentTheme->entity}['id'];
        }
    } catch (Exception $e) {
        try {
            $result = eF_getTableData("themes", "*", "name = 'default'");
            if (sizeof($result) == 0) {
                throw new Exception();
                //To be caught right below. This way, the catch() code gets executed either if the result is empty or if there is a db error
            }
        } catch (Exception $e) {
            $file = new EfrontFile(G_DEFAULTTHEMEPATH . "theme.xml");
            themes::create(themes::parseFile($file));
        }
        $currentTheme = new themes('default');
    }
    $currentThemeName = $currentTheme->{$currentTheme->entity}['name'];
    /**The current theme*/
    define("G_CURRENTTHEME", $currentThemeName);
    /** The current theme path*/
    define("G_CURRENTTHEMEPATH", !isset($currentTheme->remote) || !$currentTheme->remote ? G_THEMESPATH . $currentTheme->{$currentTheme->entity}['path'] : $currentTheme->{$currentTheme->entity}['path']);
    /** The current theme url*/
    define("G_CURRENTTHEMEURL", !isset($currentTheme->remote) || !$currentTheme->remote ? "themes/" . $currentTheme->themes['path'] : $currentTheme->{$currentTheme->entity}['path']);
    /** The external pages path*/
    define("G_EXTERNALPATH", rtrim(G_CURRENTTHEMEPATH, '/') . "/external/");
    is_dir(G_EXTERNALPATH) or mkdir(G_EXTERNALPATH, 0755);
    /** The external pages link*/
    define("G_EXTERNALURL", rtrim(G_CURRENTTHEMEURL, '/') . "/external/");
    if ($fp = fopen(G_CURRENTTHEMEPATH . "css/css_global.css", 'r')) {
        /** The current theme's css*/
        define("G_CURRENTTHEMECSS", G_CURRENTTHEMEURL . "css/css_global.css?build=" . G_BUILD);
        fclose($fp);
    } else {
        /** The current theme's css*/
        define("G_CURRENTTHEMECSS", G_DEFAULTTHEMEURL . "css/css_global.css?build=" . G_BUILD);
    }
    /** The folder where the template compiled and cached files are kept*/
    define("G_THEMECACHE", G_ROOTPATH . "libraries/smarty/themes_cache/");
    /** The folder of the current theme's compiled files*/
    define("G_CURRENTTHEMECACHE", G_THEMECACHE . $currentThemeName . "/");
    /** The full filesystem path of the images directory*/
    define("G_IMAGESPATH", G_CURRENTTHEMEPATH . "images/");
    /** The full filesystem path of the images directory, in the default theme*/
    define("G_DEFAULTIMAGESPATH", G_DEFAULTTHEMEPATH . "images/");
    /** The users' avatars directory*/
    define("G_AVATARSPATH", G_IMAGESPATH . "avatars/");
    if (is_dir(G_AVATARSPATH . "system_avatars/")) {
        /*system avatars path*/
        define("G_SYSTEMAVATARSPATH", G_AVATARSPATH . "system_avatars/");
        /*system avatars URL*/
        define("G_SYSTEMAVATARSURL", G_CURRENTTHEMEURL . "images/avatars/system_avatars/");
    } else {
        /*system avatars path*/
        define("G_SYSTEMAVATARSPATH", G_DEFAULTTHEMEPATH . "images/avatars/system_avatars/");
        /*system avatars URL*/
        define("G_SYSTEMAVATARSURL", G_DEFAULTTHEMEURL . "images/avatars/system_avatars/");
    }
    /** The logo path*/
    define("G_LOGOPATH", G_DEFAULTIMAGESPATH . "logo/");
    return $currentTheme;
}
Esempio n. 9
0
<?php

if (!defined('PHPWG_ROOT_PATH')) {
    die('Hacking attempt!');
}
include_once PHPWG_ROOT_PATH . 'admin/include/themes.class.php';
$themes = new themes();
if (isset($_POST['edit'])) {
    $_POST['theme'] = $_POST['theme_select'];
}
if (isset($_POST['theme']) and '~common~' == $_POST['theme']) {
    $page['theme'] = $_POST['theme'];
    $edited_file = PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'css/rules.css';
} else {
    if (isset($_GET['theme'])) {
        $page['theme'] = $_GET['theme'];
    } elseif (isset($_POST['theme'])) {
        $page['theme'] = $_POST['theme'];
    }
    if (!isset($page['theme']) or !in_array($page['theme'], array_keys($themes->fs_themes))) {
        $page['theme'] = get_default_theme();
    }
    $edited_file = PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'css/' . $page['theme'] . '-rules.css';
}
$template->assign('theme', $page['theme']);
if (file_exists($edited_file)) {
    $content_file = file_get_contents($edited_file);
} else {
    $content_file = "/* " . l10n('locfiledit_newfile') . " */\n\n";
}
$selected = 0;
Esempio n. 10
0
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery                                    |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2016 Piwigo Team                  http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify  |
// | it under the terms of the GNU General Public License as published by  |
// | the Free Software Foundation                                          |
// |                                                                       |
// | This program is distributed in the hope that it will be useful, but   |
// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
// | General Public License for more details.                              |
// |                                                                       |
// | You should have received a copy of the GNU General Public License     |
// | along with this program; if not, write to the Free Software           |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA.                                                                  |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH')) {
    die('Hacking attempt!');
}
$upgrade_description = 'Automatically activate mobile theme.';
include_once PHPWG_ROOT_PATH . 'include/constants.php';
include_once PHPWG_ROOT_PATH . 'admin/include/themes.class.php';
$themes = new themes();
$themes->perform_action('activate', 'smartpocket');
echo "\n" . $upgrade_description . "\n";
Esempio n. 11
0
// | This program is distributed in the hope that it will be useful, but   |
// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
// | General Public License for more details.                              |
// |                                                                       |
// | You should have received a copy of the GNU General Public License     |
// | along with this program; if not, write to the Free Software           |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA.                                                                  |
// +-----------------------------------------------------------------------+
if (!defined("PHPWG_ROOT_PATH")) {
    die("Hacking attempt!");
}
include_once PHPWG_ROOT_PATH . 'admin/include/themes.class.php';
$base_url = get_root_url() . 'admin.php?page=' . $page['page'] . '&tab=' . $page['tab'];
$themes = new themes();
// +-----------------------------------------------------------------------+
// |                           setup check                                 |
// +-----------------------------------------------------------------------+
$themes_dir = PHPWG_ROOT_PATH . 'themes';
if (!is_writable($themes_dir)) {
    $page['errors'][] = l10n('Add write access to the "%s" directory', 'themes');
}
// +-----------------------------------------------------------------------+
// |                       perform installation                            |
// +-----------------------------------------------------------------------+
if (isset($_GET['revision']) and isset($_GET['extension'])) {
    if (!is_webmaster()) {
        $page['errors'][] = l10n('Webmaster status is required.');
    } else {
        check_pwg_token();
Esempio n. 12
0
/**
 * API method
 * Performs an action on a theme
 * @param mixed[] $params
 *    @option string action
 *    @option string theme
 *    @option string pwg_token
 */
function ws_themes_performAction($params, $service)
{
    global $template;
    if (get_pwg_token() != $params['pwg_token']) {
        return new PwgError(403, 'Invalid security token');
    }
    define('IN_ADMIN', true);
    include_once PHPWG_ROOT_PATH . 'admin/include/themes.class.php';
    $themes = new themes();
    $errors = $themes->perform_action($params['action'], $params['theme']);
    if (!empty($errors)) {
        return new PwgError(500, $errors);
    } else {
        if (in_array($params['action'], array('activate', 'deactivate'))) {
            $template->delete_compiled_templates();
        }
        return true;
    }
}
Esempio n. 13
0
<?php

# lang
require_once "../src/pfci18n.class.php";
require_once "inc.conf.php";
pfcI18N::Init($lang, "admin");
# themes class
require_once "themes.class.php";
$themes = new themes();
?>

<?php 
// TOP //
include "index_html_top.php";
?>

<div class="content">
  <h2><?php 
echo _pfc("Available themes");
?>
</h2>
<?php 
$themes_list = $themes->getThemesList();
for ($i = 0; $i < count($themes_list); $i++) {
    echo "<div class=\"showbox\">";
    echo "<h4><a href=\"#\" onclick=\"openClose('{$themes_list[$i]}', 0); return false;\">" . $themes_list[$i] . "</a>";
    $info = $themes->getThemeInfo($themes_list[$i]);
    if ($info != '0') {
        echo " ( {$info} ) ";
    }
    echo "</h4>";
Esempio n. 14
0
 //Try to restore custom blocks
 try {
     if ($options['custom_blocks']) {
         $basedir = G_EXTERNALPATH;
         if (!is_dir($basedir) && !mkdir($basedir, 0755)) {
             throw new EfrontFileException(_COULDNOTCREATEDIRECTORY . ': ' . $fullPath, EfrontFileException::CANNOT_CREATE_DIR);
         }
         $blocks = unserialize($options['custom_blocks']);
         foreach ($blocks as $value) {
             $value['name'] = rand() . time();
             //Use a random name
             $block = array('name' => $value['name'], 'title' => $value['title']);
             file_put_contents($basedir . $value['name'] . '.tpl', $value['content']);
             isset($customBlocks) && sizeof($customBlocks) > 0 ? $customBlocks[] = $block : ($customBlocks = array($block));
         }
         $currentSetTheme = new themes($GLOBALS['configuration']['theme']);
         $currentSetTheme->layout['custom_blocks'] = $customBlocks;
         $currentSetTheme->persist();
     }
 } catch (Exception $e) {
 }
 //Try to restore custom logo
 try {
     $logoFile = new EfrontFile($options['logo']);
     if (strpos($logoFile['path'], G_LOGOPATH) === false) {
         copy($logoFile['path'], G_LOGOPATH . $logoFile['name']);
     }
 } catch (Exception $e) {
 }
 //Try to restore custom favicon
 try {