|
From: <bi...@us...> - 2013-02-12 02:08:43
|
Revision: 11029
http://sourceforge.net/p/xoops/svn/11029
Author: bitc3r0
Date: 2013-02-12 02:08:36 +0000 (Tue, 12 Feb 2013)
Log Message:
-----------
xthemes first commit
Added Paths:
-----------
RMC/modules/xthemes/trunk/xthemes/class/
RMC/modules/xthemes/trunk/xthemes/class/index.html
RMC/modules/xthemes/trunk/xthemes/class/standardtheme.class.php
RMC/modules/xthemes/trunk/xthemes/class/xtassembler.class.php
RMC/modules/xthemes/trunk/xthemes/class/xtcolor.class.php
RMC/modules/xthemes/trunk/xthemes/class/xtfeedparser.class.php
RMC/modules/xthemes/trunk/xthemes/class/xtfunctions.class.php
RMC/modules/xthemes/trunk/xthemes/class/xttheme.php
RMC/modules/xthemes/trunk/xthemes/css/
RMC/modules/xthemes/trunk/xthemes/css/dashboard.css
RMC/modules/xthemes/trunk/xthemes/css/index.html
RMC/modules/xthemes/trunk/xthemes/css/settings.css
RMC/modules/xthemes/trunk/xthemes/css/themes.css
RMC/modules/xthemes/trunk/xthemes/events/
RMC/modules/xthemes/trunk/xthemes/events/index.html
RMC/modules/xthemes/trunk/xthemes/events/rmcommon.php
RMC/modules/xthemes/trunk/xthemes/images/
RMC/modules/xthemes/trunk/xthemes/images/about.png
RMC/modules/xthemes/trunk/xthemes/images/catalog.png
RMC/modules/xthemes/trunk/xthemes/images/dashboard.png
RMC/modules/xthemes/trunk/xthemes/images/error.png
RMC/modules/xthemes/trunk/xthemes/images/icons.png
RMC/modules/xthemes/trunk/xthemes/images/index.html
RMC/modules/xthemes/trunk/xthemes/images/logo.png
RMC/modules/xthemes/trunk/xthemes/images/options.png
RMC/modules/xthemes/trunk/xthemes/images/searching.gif
RMC/modules/xthemes/trunk/xthemes/images/sections.png
RMC/modules/xthemes/trunk/xthemes/images/settings.png
RMC/modules/xthemes/trunk/xthemes/images/spacer.png
RMC/modules/xthemes/trunk/xthemes/images/themes.png
RMC/modules/xthemes/trunk/xthemes/images/xthemes.png
RMC/modules/xthemes/trunk/xthemes/images/xthemes24.png
RMC/modules/xthemes/trunk/xthemes/images/xthemes32.png
RMC/modules/xthemes/trunk/xthemes/images/xthemes48.png
RMC/modules/xthemes/trunk/xthemes/index.php
RMC/modules/xthemes/trunk/xthemes/js/
RMC/modules/xthemes/trunk/xthemes/js/dashboard.js
RMC/modules/xthemes/trunk/xthemes/js/index.html
RMC/modules/xthemes/trunk/xthemes/js/jquery.nestedSortable.js
RMC/modules/xthemes/trunk/xthemes/js/json_encode.js
RMC/modules/xthemes/trunk/xthemes/js/xthemes.js
RMC/modules/xthemes/trunk/xthemes/lang/
RMC/modules/xthemes/trunk/xthemes/lang/en.po
RMC/modules/xthemes/trunk/xthemes/lang/es.mo
RMC/modules/xthemes/trunk/xthemes/lang/es.po
RMC/modules/xthemes/trunk/xthemes/lang/index.html
RMC/modules/xthemes/trunk/xthemes/menu.php
RMC/modules/xthemes/trunk/xthemes/navigation.php
RMC/modules/xthemes/trunk/xthemes/preloads/
RMC/modules/xthemes/trunk/xthemes/preloads/core.php
RMC/modules/xthemes/trunk/xthemes/preloads/index.html
RMC/modules/xthemes/trunk/xthemes/settings.php
RMC/modules/xthemes/trunk/xthemes/smarty/
RMC/modules/xthemes/trunk/xthemes/smarty/block.htmlhead.php
RMC/modules/xthemes/trunk/xthemes/smarty/function.locale.php
RMC/modules/xthemes/trunk/xthemes/smarty/index.html
RMC/modules/xthemes/trunk/xthemes/sql/
RMC/modules/xthemes/trunk/xthemes/sql/index.html
RMC/modules/xthemes/trunk/xthemes/sql/mysql.sql
RMC/modules/xthemes/trunk/xthemes/templates/
RMC/modules/xthemes/trunk/xthemes/templates/index.html
RMC/modules/xthemes/trunk/xthemes/templates/widgets/
RMC/modules/xthemes/trunk/xthemes/templates/widgets/index.html
RMC/modules/xthemes/trunk/xthemes/templates/widgets/xt_wgt_sections.php
RMC/modules/xthemes/trunk/xthemes/templates/widgets/xt_wgt_themeinfo.php
RMC/modules/xthemes/trunk/xthemes/templates/widgets/xt_wgt_themeoptions.php
RMC/modules/xthemes/trunk/xthemes/templates/xt_index.php
RMC/modules/xthemes/trunk/xthemes/templates/xt_menu_manager.php
RMC/modules/xthemes/trunk/xthemes/templates/xt_navigation.php
RMC/modules/xthemes/trunk/xthemes/templates/xt_settings.php
RMC/modules/xthemes/trunk/xthemes/templates/xt_themes.php
RMC/modules/xthemes/trunk/xthemes/theme.php
RMC/modules/xthemes/trunk/xthemes/themes.php
RMC/modules/xthemes/trunk/xthemes/xoops_version.php
Added: RMC/modules/xthemes/trunk/xthemes/class/index.html
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/class/index.html (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/class/index.html 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1 @@
+ <script>history.go(-1);</script>
\ No newline at end of file
Added: RMC/modules/xthemes/trunk/xthemes/class/standardtheme.class.php
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/class/standardtheme.class.php (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/class/standardtheme.class.php 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1,42 @@
+<?php
+// $Id: standardtheme.class.php 99 2012-10-24 21:46:58Z i.bitcero $
+// --------------------------------------------------------------
+// xThemes for XOOPS
+// Module for manage themes by Red Mexico
+// Author: Eduardo Cortés <i.b...@gm...>
+// License: GPL v2
+// --------------------------------------------------------------
+
+class StandardTheme extends XtTheme implements XtITheme
+{
+ public function details(){
+
+ $details = array(
+ 'name' => '',
+ 'description' => 'Theme based on original FastPage template from AtomicWebsiteTemplates.com',
+ 'version' => '1.0',
+ 'author' => 'Not provided',
+ 'uri' => '',
+ 'author_uri' => '',
+ 'author_email' => '',
+ 'license' => 'Not specified',
+ 'screenshot' => 'screenshot.png',
+ 'type' => 'standard'
+ );
+
+ return $details;
+
+ }
+
+ public function set_dir($dir){
+
+ $this->details['dir'] = $dir;
+ $this->details['name'] = ucfirst($dir);
+
+ }
+
+ public function haveMenus(){return false;}
+ public function options(){return false;}
+ public function init(){}
+
+}
Added: RMC/modules/xthemes/trunk/xthemes/class/xtassembler.class.php
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/class/xtassembler.class.php (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/class/xtassembler.class.php 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1,275 @@
+<?php
+// $Id: xtassembler.class.php 159 2012-12-06 23:51:54Z i.bitcero $
+// --------------------------------------------------------------
+// xThemes for XOOPS
+// Module for manage themes by Red Mexico
+// Author: Eduardo Cortés <i.b...@gm...>
+// License: GPL v2
+// --------------------------------------------------------------
+
+// Load required classes
+include_once XTPATH.'/class/xttheme.php';
+include_once XTPATH.'/class/xtcolor.class.php';
+include_once XTPATH.'/class/standardtheme.class.php';
+include_once XTPATH.'/class/xtfunctions.class.php';
+
+/**
+* This class is the main controller for xThemes
+*/
+class XtAssembler
+{
+ private $current = null;
+ private $root_menus = null;
+ private $menus = null;
+ private $registered = array();
+ private $colors = '';
+
+ public function __construct($theme = ''){
+
+ global $xoopsConfig;
+
+ $theme = $theme!='' ? $theme : $xoopsConfig['theme_set'];
+ $dir = XOOPS_THEME_PATH.'/'.($theme=='' ? $xoopsConfig['theme_set'] : $theme);
+
+ if(!is_file($dir.'/assemble/'.$theme.'.theme.php')){
+ $this->current = new StandardTheme();
+ $this->current->set_dir($theme);
+ return;
+ }
+
+ require_once $dir.'/assemble/'.$theme.'.theme.php';
+ $class = ucfirst($theme);
+ $this->current = new $class();
+
+ /**
+ * The theme support native menus?
+ */
+ $this->root_menus = $this->current->haveMenus();
+
+ /**
+ * Load theme configuration
+ */
+ $this->current->setSettings($this->load_settings());
+ /*
+ * @todo Agregar código para carga de métodos del tema
+ */
+ $this->loadMenus();
+
+ // Register pluguins
+ if(method_exists($this->current, 'register')){
+
+ $plugins = $this->theme()->register();
+
+ $dir = str_replace(XOOPS_URL, XOOPS_ROOT_PATH, $this->theme()->url().'/assemble/plugins');
+ foreach($plugins as $plug){
+ if(!file_exists($dir.'/'.$plug['file'])) continue;
+
+ include_once $dir.'/'.$plug['file'];
+ $this->registered[$plug['var']] = new $plug['name']();
+
+ }
+
+ }
+
+ }
+
+ /**
+ * This function reload the current theme
+ */
+ public function loadTheme($theme){
+ $this->__construct($theme);
+ }
+
+ /**
+ * Init data for theme rendering
+ */
+ public function init(){
+
+ global $xoopsTpl, $xoopsConfig, $rmc_config, $xoTheme;
+
+ if(!$this->isSupported()) return;
+
+ if($this->current->getInfo('dir')!=$xoopsConfig['theme_set']){
+
+ // If user has selected another theme, realod all theme data
+ $dir = XOOPS_THEME_PATH.'/'.$xoopsConfig['theme_set'];
+
+ if(!is_file($dir.'/assemble/'.$xoopsConfig['theme_set'].'.theme.php')){
+ $this->current = new StandardTheme();
+ $this->current->set_dir($xoopsConfig['theme_set']);
+ return;
+ }
+
+ require_once $dir.'/assemble/'.$xoopsConfig['theme_set'].'.theme.php';
+ $class = ucfirst($xoopsConfig['theme_set']);
+ $this->current = new $class();
+
+ /**
+ * The theme support native menus?
+ */
+ $this->root_menus = $this->current->haveMenus();
+
+ /**
+ * Load theme configuration
+ */
+ $this->current->setSettings($this->load_settings());
+ /*
+ * @todo Agregar código para carga de métodos del tema
+ */
+ $this->loadMenus();
+
+ // Register pluguins
+ if(method_exists($this->current, 'register')){
+
+ $plugins = $this->theme()->register();
+
+ $dir = str_replace(XOOPS_URL, XOOPS_ROOT_PATH, $this->theme()->url().'/assemble/plugins');
+ foreach($plugins as $plug){
+ if(!file_exists($dir.'/'.$plug['file'])) continue;
+
+ include_once $dir.'/'.$plug['file'];
+ $this->registered[$plug['var']] = new $plug['name']();
+
+ }
+
+ }
+
+ }
+
+ $xoopsTpl->assign('theme', $this->theme());
+ $xoopsTpl->assign('xtConfig', $this->theme()->settings());
+ $xoopsTpl->assign('xt_language', $rmc_config['lang']);
+ $xoopsTpl->assign('isHome', defined('XTHEMES_IS_HOME'));
+
+ $this->colors = new XtColor();
+ $xoopsTpl->assign('xtColor', $this->colors);
+
+ // Assign plugins
+ foreach($this->registered as $id => $o){
+ $xoopsTpl->assign($id, $o);
+ }
+
+ // Register smarty plugins
+ $dir = str_replace(XOOPS_URL, XOOPS_ROOT_PATH, $this->theme()->url());
+
+ $xoopsTpl->plugins_dir[] = XOOPS_ROOT_PATH.'/modules/xthemes/smarty';
+ $xoopsTpl->plugins_dir[] = $dir.'/assemble/smarty';
+
+ load_theme_locale($this->theme()->getInfo('dir'));
+
+ $this->current->init();
+
+ }
+
+ /**
+ * Access to registered plugins
+ */
+ public function plugin($name){
+
+ if($name=='' || !isset($this->registered[$name])) return false;
+
+ return $this->registered[$name];
+
+ }
+
+ /**
+ * Determines if current page is the homepage
+ */
+ public function isHome(){
+ return defined('XTHEMES_IS_HOME');
+ }
+
+ /**
+ * Load theme settings from database
+ */
+ private function load_settings(){
+
+ $db = XoopsDatabaseFactory::getDatabaseConnection();
+ $sql = "SELECT * FROM ".$db->prefix("xt_options")." WHERE theme=".$this->current->id();
+ $result = $db->query($sql);
+
+ $settings = array();
+
+ while($row = $db->fetchArray($result)){
+ $settings[$row['name']] = $row['type']=='array' ? unserialize(trim($row['value'])) : $row['value'];
+ }
+
+ return $settings;
+
+ }
+
+ /**
+ * Load confgiured menus from database
+ * @return array
+ * @return bool
+ */
+ private function loadMenus(){
+
+ $db = XoopsDatabaseFactory::getDatabaseConnection();
+ $sql = "SELECT * FROM ".$db->prefix("xt_menus")." WHERE theme=".$this->current->id()." AND (";
+ $sqlm = '';
+
+ foreach($this->root_menus as $id => $menu){
+ $sqlm .= $sqlm=='' ? "menu='".$id."'" : " OR menu='".$id."'";
+ }
+ $sql .= $sqlm.')';
+ unset($sqlm);
+
+ $result = $db->query($sql);
+ $this->menus = array();
+
+ while($row = $db->fetchArray($result)){
+ $this->menus[$row['menu']] = unserialize($row['content']);
+ }
+
+ }
+
+ /**
+ * Get configured menus from database
+ * @return array
+ * @return false
+ */
+ public function menu($id = ''){
+
+ if($id=='') return $this->menus;
+
+ if(!isset($this->menus[$id])) return false;
+
+ return $this->menus[$id];
+
+ }
+
+ /**
+ * @return Theme Object
+ */
+ public function theme(){return $this->current;}
+
+ /**
+ * @return $xtColor class
+ */
+ public function colorControl(){
+
+ if(!is_object($this->colors))
+ $this->colors = new XtColor();
+
+ return $this->colors;
+ }
+
+ /**
+ * Return the accepted menus from theme
+ * @return array
+ */
+ public function rootMenus(){
+ return $this->root_menus;
+ }
+
+ /**
+ * Determines if the theme is supported
+ */
+ public function isSupported(){
+
+ return !is_a($this->current, 'StandardTheme');
+
+ }
+
+}
Added: RMC/modules/xthemes/trunk/xthemes/class/xtcolor.class.php
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/class/xtcolor.class.php (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/class/xtcolor.class.php 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1,420 @@
+<?php
+/*
+Based on phpColor, a class by Arlo Carreon
+Copyright © 2012 Arlo Carreon, http://arlocarreon.com
+*/
+
+/**
+ * A color utility that helps manipulate HEX colors
+ */
+class XtColor {
+
+ private $_hex;
+ private $_hsl;
+
+ /**
+ * Auto darkens/lightens by 10% for sexily-subtle gradients.
+ * Set this to FALSE to adjust automatic shade to be between given color
+ * and black (for darken) or white (for lighten)
+ */
+ const DEFAULT_ADJUST = 10;
+
+ /**
+ * Instantiates the class with a HEX value
+ * @param string $hex
+ */
+ function __construct( $hex = '' ) {
+
+ if($hex!='')
+ $this->prepareColor($hex);
+
+ }
+
+ // ====================
+ // = Public Interface =
+ // ====================
+
+ /**
+ * Prepares initial color
+ */
+ public function prepareColor($hex){
+ // Strip # sign is present
+ $color = str_replace("#", "", $hex);
+
+ // Make sure it's 6 digits
+ if( strlen($color) === 3 ) {
+ $color = $color[0].$color[0].$color[1].$color[1].$color[2].$color[2];
+ } else if( strlen($color) != 6 ) {
+
+ throw new Exception("HEX color needs to be 6 or 3 digits long");
+ }
+
+ $this->_hsl = self::hexToHsl( $color );
+ $this->_hex = $color;
+
+ }
+
+ /**
+ * Given a HEX string returns a HSL array equivalent.
+ * @param string $color
+ * @return array HSL associative array
+ */
+ public static function hexToHsl( $color ){
+
+ // Sanity check
+ $color = self::_checkHex($color);
+
+ // Convert HEX to DEC
+ $R = hexdec($color[0].$color[1]);
+ $G = hexdec($color[2].$color[3]);
+ $B = hexdec($color[4].$color[5]);
+
+ $HSL = array();
+
+ $var_R = ($R / 255);
+ $var_G = ($G / 255);
+ $var_B = ($B / 255);
+
+ $var_Min = min($var_R, $var_G, $var_B);
+ $var_Max = max($var_R, $var_G, $var_B);
+ $del_Max = $var_Max - $var_Min;
+
+ $L = ($var_Max + $var_Min)/2;
+
+ if ($del_Max == 0)
+ {
+ $H = 0;
+ $S = 0;
+ }
+ else
+ {
+ if ( $L < 0.5 ) $S = $del_Max / ( $var_Max + $var_Min );
+ else $S = $del_Max / ( 2 - $var_Max - $var_Min );
+
+ $del_R = ( ( ( $var_Max - $var_R ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
+ $del_G = ( ( ( $var_Max - $var_G ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
+ $del_B = ( ( ( $var_Max - $var_B ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
+
+ if ($var_R == $var_Max) $H = $del_B - $del_G;
+ else if ($var_G == $var_Max) $H = ( 1 / 3 ) + $del_R - $del_B;
+ else if ($var_B == $var_Max) $H = ( 2 / 3 ) + $del_G - $del_R;
+
+ if ($H<0) $H++;
+ if ($H>1) $H--;
+ }
+
+ $HSL['H'] = ($H*360);
+ $HSL['S'] = $S;
+ $HSL['L'] = $L;
+
+ return $HSL;
+ }
+
+ /**
+ * Given a HSL associative array returns the equivalent HEX string
+ * @param array $hsl
+ * @return string HEX string
+ * @throws Exception "Bad HSL Array"
+ */
+ public static function hslToHex( $hsl = array() ){
+ // Make sure it's HSL
+ if(empty($hsl) || !isset($hsl["H"]) || !isset($hsl["S"]) || !isset($hsl["L"]) ) {
+ throw new Exception("Param was not an HSL array");
+ }
+
+ list($H,$S,$L) = array( $hsl['H']/360,$hsl['S'],$hsl['L'] );
+
+ if( $S == 0 ) {
+ $r = $L * 255;
+ $g = $L * 255;
+ $b = $L * 255;
+ } else {
+
+ if($L<0.5) {
+ $var_2 = $L*(1+$S);
+ } else {
+ $var_2 = ($L+$S) - ($S*$L);
+ }
+
+ $var_1 = 2 * $L - $var_2;
+
+ $r = round(255 * self::_huetorgb( $var_1, $var_2, $H + (1/3) ));
+ $g = round(255 * self::_huetorgb( $var_1, $var_2, $H ));
+ $b = round(255 * self::_huetorgb( $var_1, $var_2, $H - (1/3) ));
+
+ }
+
+ // Convert to hex
+ $r = dechex($r);
+ $g = dechex($g);
+ $b = dechex($b);
+
+ // Make sure we get 2 digits for decimals
+ $r = (strlen("".$r)===1) ? "0".$r:$r;
+ $g = (strlen("".$g)===1) ? "0".$g:$g;
+ $b = (strlen("".$b)===1) ? "0".$b:$b;
+
+ return $r.$g.$b;
+ }
+
+ /**
+ * Given a HEX value, returns a darker color. If no desired amount provided, then the color halfway between
+ * given HEX and black will be returned.
+ * @param int $amount
+ * @return string Darker HEX value
+ */
+ public function darken( $hex='', $amount = self::DEFAULT_ADJUST ){
+
+ if($hex!='')
+ $this->prepareColor($hex);
+
+ // Darken
+ $darkerHSL = $this->_darken($this->_hsl, $amount);
+ // Return as HEX
+ return self::hslToHex($darkerHSL);
+ }
+
+ /**
+ * Given a HEX value, returns a lighter color. If no desired amount provided, then the color halfway between
+ * given HEX and white will be returned.
+ * @param int $amount
+ * @return string Lighter HEX value
+ */
+ public function lighten( $hex='', $amount = self::DEFAULT_ADJUST ){
+
+ if($hex!='')
+ $this->prepareColor($hex);
+
+ // Lighten
+ $lighterHSL = $this->_lighten($this->_hsl, $amount);
+ // Return as HEX
+ return self::hslToHex($lighterHSL);
+ }
+
+ /**
+ * Creates an array with two shades that can be used to make a gradient
+ * @param int $amount Optional percentage amount you want your contrast color
+ * @return array An array with a 'light' and 'dark' index
+ */
+ public function makeGradient( $hex, $amount = self::DEFAULT_ADJUST ) {
+
+ $this->prepareColor($hex);
+
+ // Decide which color needs to be made
+ if( $this->isLight() ) {
+ $lightColor = $this->_hex;
+ $darkColor = $this->darken('',$amount);
+ } else {
+ $lightColor = $this->lighten('',$amount);
+ $darkColor = $this->_hex;
+ }
+
+ // Return our gradient array
+ return array( "light" => $lightColor, "dark" => $darkColor );
+ }
+
+
+ /**
+ * Returns whether or not given color is considered "light"
+ * @param string|Boolean $color
+ * @return boolean
+ */
+ public function isLight( $color = FALSE ){
+ // Get our color
+ $color = ($color) ? str_replace("#", '', $color) : $this->_hex;
+
+ // Calculate straight from rbg
+ $r = hexdec($color[0].$color[1]);
+ $g = hexdec($color[2].$color[3]);
+ $b = hexdec($color[4].$color[5]);
+
+ return (( $r*299 + $g*587 + $b*114 )/1000 > 130);
+ }
+
+ /**
+ * Returns whether or not a given color is considered "dark"
+ * @param string|Boolean $color
+ * @return boolean
+ */
+ public function isDark( $color = FALSE ){
+ // Get our color
+ $color = ($color) ? $color:$this->_hex;
+
+ // Calculate straight from rbg
+ $r = hexdec($color[0].$color[1]);
+ $g = hexdec($color[2].$color[3]);
+ $b = hexdec($color[4].$color[5]);
+
+ return (( $r*299 + $g*587 + $b*114 )/1000 <= 130);
+ }
+
+ /**
+ * Returns the complimentary color
+ * @return string Complementary hex color
+ *
+ */
+ public function complementary($hex='') {
+
+ if($hex!='')
+ $this->prepareColor($hex);
+
+ // Get our HSL
+ $hsl = $this->_hsl;
+
+ // Adjust Hue 180 degrees
+ $hsl['H'] += ($hsl['H']>180) ? -180:180;
+
+ // Return the new value in HEX
+ return self::hslToHex($hsl);
+ }
+
+ /**
+ * Returns your colors HSL array
+ */
+ public function getHsl($hex='') {
+ if($hex!='')
+ $this->prepareColor($hex);
+ return $this->_hsl;
+ }
+ /**
+ * Returns your original color
+ */
+ public function getHex($hex='') {
+ if($hex!='')
+ $this->prepareColor($hex);
+ return $this->_hex;
+ }
+ /**
+ * Returns the cross browser CSS3 gradient
+ * @param int Optional: percentage amount to light/darken the gradient
+ * @param string $prefix Optional: prefix for every lines
+ * @param string $suffix Optional: suffix for every lines
+ * @return string CSS3 gradient for chrome, safari, firefox, opera and IE10
+ */
+ public function getCssGradient($hex, $amount = self::DEFAULT_ADJUST, $suffix = "" , $prefix = "" ) {
+
+ // Get the recommended gradient
+ $g = $this->makeGradient($hex, $amount);
+
+ $css = "";
+ /* fallback/image non-cover color */
+ $css .= "{$prefix}background-color: #".$this->_hex.";{$suffix}";
+
+ /* IE Browsers */
+ $css .= "{$prefix}filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#".$g['light']."', endColorstr='#".$g['dark']."');{$suffix}";
+
+ /* Safari 4+, Chrome 1-9 */
+ $css .= "{$prefix}background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#".$g['light']."), to(#".$g['dark']."));{$suffix}";
+
+ /* Safari 5.1+, Mobile Safari, Chrome 10+ */
+ $css .= "{$prefix}background-image: -webkit-linear-gradient(top, #".$g['light'].", #".$g['dark'].");{$suffix}";
+
+ /* Firefox 3.6+ */
+ $css .= "{$prefix}background-image: -moz-linear-gradient(top, #".$g['light'].", #".$g['dark'].");{$suffix}";
+
+ /* IE 10+ */
+ $css .= "{$prefix}background-image: -ms-linear-gradient(top, #".$g['light'].", #".$g['dark'].");{$suffix}";
+
+ /* Opera 11.10+ */
+ $css .= "{$prefix}background-image: -o-linear-gradient(top, #".$g['light'].", #".$g['dark'].");{$suffix}";
+
+ // Return our CSS
+ return $css;
+ }
+
+ // ===========================
+ // = Private Functions Below =
+ // ===========================
+
+
+ /**
+ * Darkens a given HSL array
+ * @param array $hsl
+ * @param int $amount
+ * @return array $hsl
+ */
+ private function _darken( $hsl, $amount = self::DEFAULT_ADJUST){
+ // Check if we were provided a number
+ if( $amount ) {
+ $hsl['L'] = ($hsl['L'] * 100) - $amount;
+ $hsl['L'] = ($hsl['L'] < 0) ? 0:$hsl['L']/100;
+ } else {
+ // We need to find out how much to darken
+ $hsl['L'] = $hsl['L']/2 ;
+ }
+
+ return $hsl;
+ }
+
+ /**
+ * Lightens a given HSL array
+ * @param array $hsl
+ * @param int $amount
+ * @return array $hsl
+ */
+ private function _lighten( $hsl, $amount = self::DEFAULT_ADJUST){
+ // Check if we were provided a number
+ if( $amount ) {
+ $hsl['L'] = ($hsl['L'] * 100) + $amount;
+ $hsl['L'] = ($hsl['L'] > 100) ? 1:$hsl['L']/100;
+ } else {
+ // We need to find out how much to lighten
+ $hsl['L'] += (1-$hsl['L'])/2;
+ }
+
+ return $hsl;
+ }
+
+ /**
+ * Given a Hue, returns corresponding RGB value
+ * @param type $v1
+ * @param type $v2
+ * @param type $vH
+ * @return int
+ */
+ private static function _huetorgb( $v1,$v2,$vH ) {
+ if( $vH < 0 ) {
+ $vH += 1;
+ }
+
+ if( $vH > 1 ) {
+ $vH -= 1;
+ }
+
+ if( (6*$vH) < 1 ) {
+ return ($v1 + ($v2 - $v1) * 6 * $vH);
+ }
+
+ if( (2*$vH) < 1 ) {
+ return $v2;
+ }
+
+ if( (3*$vH) < 2 ) {
+ return ($v1 + ($v2-$v1) * ( (2/3)-$vH ) * 6);
+ }
+
+ return $v1;
+
+ }
+
+ /**
+ * You need to check if you were given a good hex string
+ * @param string $hex
+ * @return string Color
+ * @throws Exception "Bad color format"
+ */
+ private static function _checkHex( $hex ) {
+ // Strip # sign is present
+ $color = str_replace("#", "", $hex);
+
+ // Make sure it's 6 digits
+ if( strlen($color) == 3 ) {
+ $color = $color[0].$color[0].$color[1].$color[1].$color[2].$color[2];
+ } else if( strlen($color) != 6 ) {
+ throw new Exception("HEX color needs to be 6 or 3 digits long");
+ }
+
+ return $color;
+ }
+
+}
\ No newline at end of file
Added: RMC/modules/xthemes/trunk/xthemes/class/xtfeedparser.class.php
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/class/xtfeedparser.class.php (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/class/xtfeedparser.class.php 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1,554 @@
+<?php
+ /*=======================================================================+
+ | PHP Universal Feed Parser |
+ +------------------------------------------------------------------------/
+
+ Author : Anis uddin Ahmad <ad...@aj...>
+ Web : http://www.ajaxray.com
+ Publish Date : March 24, 2008
+
+LICENSE
+----------------------------------------------------------------------
+PHP Universal Feed Parser 1.0 - A PHP class to parse RSS 1.0, RSS 2.0 and ATOM 1.0 feed.
+Copyright (C) 2008 Anis uddin Ahmad <ad...@aj...>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License (GPL)
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+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.
+
+To read the license please visit http://www.gnu.org/copyleft/gpl.html
+=======================================================================
+
+HOW TO USE
+-----------------------------------------------------------------------
+It's very easy to use. Just follow this 3 steps:
+1. Include the file
+ include('FeedParser.php');
+2. Create an object of FeedParser class
+ $Parser = new FeedParser();
+3. Parse the URL you want to featch
+ $Parser->parse('http://www.sitepoint.com/rss.php');
+
+Done.
+Now you can use this functions to get various information of parsed feed:
+ 1. $Parser->getChannels() - To get all channel elements as array
+ 2. $Parser->getItems() - To get all feed elements as array
+ 3. $Parser->getChannel($name) - To get a channel element by name
+ 4. $Parser->getItem($index) - To get a feed element as array by it's index
+ 5. $Parser->getTotalItems() - To get the number of total feed elements
+ 6. $Parser->getFeedVersion() - To get the detected version of parsed feed
+ 7. $Parser->getParsedUrl() - To get the parsed feed URL
+
+=======================================================================
+
+IMPORTANT NOTES
+-----------------------------------------------------------------------
+1. All array keys are must be UPPERCASE
+2. All dates are converted to timestamp
+3. Attributes of a tag will be found under TAGNAME_ATTRS index
+ example: Attributes of $item['GUID'] will be found as $item['GUID_ATTRS']
+4. The tags which have subtags will be an array and sub tags will be found as it's element
+ example: IMAGE tag in RSS 2.0
+========================================================================
+
+EXAMPLES
+-----------------------------------------------------------------------
+To see more details and examples, please visit:
+ http://www.ajaxray.com/blog/2008/05/02/php-universal-feed-parser-lightweight-php-class-for-parsing-rss-and-atom-feeds/
+========================================================================
+*/
+
+/**
+* PHP Univarsel Feed Parser class
+*
+* Parses RSS 1.0, RSS2.0 and ATOM Feed
+*
+* @license GNU General Public License (GPL)
+* @author Anis uddin Ahmad <ad...@aj...>
+* @link http://www.ajaxray.com/blog/2008/05/02/php-universal-feed-parser-lightweight-php-class-for-parsing-rss-and-atom-feeds/
+*/
+class XtFeedParser{
+
+ private $xmlParser = null;
+ private $insideItem = array(); // Keep track of current position in tag tree
+ private $currentTag = null; // Last entered tag name
+ private $currentAttr = null; // Attributes array of last entered tag
+
+ private $namespaces = array(
+ 'http://purl.org/rss/1.0/' => 'RSS 1.0',
+ 'http://purl.org/rss/1.0/modules/content/' => 'RSS 2.0',
+ 'http://www.w3.org/2005/Atom' => 'ATOM 1',
+ ); // Namespaces to detact feed version
+ private $itemTags = array('ITEM','ENTRY'); // List of tag names which holds a feed item
+ private $channelTags = array('CHANNEL','FEED'); // List of tag names which holds all channel elements
+ private $dateTags = array('UPDATED','PUBDATE','DC:DATE');
+ private $hasSubTags = array('IMAGE','AUTHOR'); // List of tag names which have sub tags
+ private $channels = array();
+ private $items = array();
+ private $itemIndex = 0;
+
+ private $url = null; // The parsed url
+ private $version = 'RSS 2.0'; // Detected feed version
+
+
+ /**
+ * Constructor - Initialize and set event handler functions to xmlParser
+ */
+ function __construct()
+ {
+ $this->xmlParser = xml_parser_create();
+
+ xml_set_object($this->xmlParser, $this);
+ xml_set_element_handler($this->xmlParser, "startElement", "endElement");
+ xml_set_character_data_handler($this->xmlParser, "characterData");
+ }
+
+ /*-----------------------------------------------------------------------+
+ | Public functions. Use to parse feed and get informations. |
+ +-----------------------------------------------------------------------*/
+
+ /**
+ * Get all channel elements
+ *
+ * @access public
+ * @return array - All chennels as associative array
+ */
+ public function getChannels()
+ {
+ return $this->channels;
+ }
+
+ /**
+ * Get all feed items
+ *
+ * @access public
+ * @return array - All feed items as associative array
+ */
+ public function getItems()
+ {
+ return $this->items;
+ }
+
+ /**
+ * Get total number of feed items
+ *
+ * @access public
+ * @return number
+ */
+ public function getTotalItems()
+ {
+ return count($this->items);
+ }
+
+ /**
+ * Get a feed item by index
+ *
+ * @access public
+ * @param number index of feed item
+ * @return array feed item as associative array of it's elements
+ */
+ public function getItem($index)
+ {
+ if($index < $this->getTotalItems())
+ {
+ return $this->items[$index];
+ }
+ else
+ {
+ throw new Exception("Item index is learger then total items.");
+ return false;
+ }
+ }
+
+ /**
+ * Get a channel element by name
+ *
+ * @access public
+ * @param string the name of channel tag
+ * @return string
+ */
+ public function getChannel($tagName)
+ {
+ if(array_key_exists(strtoupper($tagName), $this->channels))
+ {
+ return $this->channels[strtoupper($tagName)];
+ }
+ else
+ {
+ throw new Exception("Channel tag $tagName not found.");
+ return false;
+ }
+ }
+
+ /**
+ * Get the parsed URL
+ *
+ * @access public
+ * @return string
+ */
+ public function getParsedUrl()
+ {
+ if(empty($this->url))
+ {
+ throw new Exception("Feed URL is not set yet.");
+ return FALSE;
+ }
+ else
+ {
+ return $this->url;
+ }
+
+
+ }
+
+ /**
+ * Get the detected Feed version
+ *
+ * @access public
+ * @return string
+ */
+ public function getFeedVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Parses a feed url
+ *
+ * @access public
+ * @param srting teh feed url
+ * @return void
+ */
+ public function parse($url)
+ {
+ $this->url = $url;
+ $URLContent = $this->getUrlContent();
+
+ if($URLContent)
+ {
+ $segments = str_split($URLContent, 4096);
+ foreach($segments as $index=>$data)
+ {
+ $lastPiese = ((count($segments)-1) == $index)? true : false;
+ xml_parse($this->xmlParser, $data, $lastPiese)
+ or die(sprintf("XML error: %s at line %d",
+ xml_error_string(xml_get_error_code($this->xmlParser)),
+ xml_get_current_line_number($this->xmlParser)));
+ }
+ xml_parser_free($this->xmlParser);
+ }
+ else
+ {
+ die('Sorry! cannot load the feed url.');
+ }
+
+ if(empty($this->version))
+ {
+ die('Sorry! cannot detect the feed version.');
+ }
+ }
+
+ // End public functions -------------------------------------------------
+
+ /*-----------------------------------------------------------------------+
+ | Private functions. Be careful to edit them. |
+ +-----------------------------------------------------------------------*/
+
+ /**
+ * Load the whole contents of a RSS/ATOM page
+ *
+ * @access private
+ * @return string
+ */
+ private function getUrlContent()
+ {
+ if(empty($this->url))
+ {
+ throw new Exception("URL to parse is empty!.");
+ return false;
+ }
+
+ if($content = @file_get_contents($this->url))
+ {
+ return $content;
+ }
+ else
+ {
+ $ch = curl_init();
+
+ curl_setopt($ch, CURLOPT_URL, $this->url);
+ curl_setopt($ch, CURLOPT_HEADER, false);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ $content = curl_exec($ch);
+ $error = curl_error($ch);
+
+ curl_close($ch);
+
+ if(empty($error))
+ {
+ return $content;
+ }
+ else
+ {
+ throw new Exception("Erroe occured while loading url by cURL. <br />\n" . $error) ;
+ return false;
+ }
+ }
+
+ }
+
+ /**
+ * Handle the start event of a tag while parsing
+ *
+ * @access private
+ * @param object the xmlParser object
+ * @param string name of currently entering tag
+ * @param array array of attributes
+ * @return void
+ */
+ private function startElement($parser, $tagName, $attrs)
+ {
+ if(!$this->version)
+ {
+ $this->findVersion($tagName, $attrs);
+ }
+
+ array_push($this->insideItem, $tagName);
+
+ $this->currentTag = $tagName;
+ $this->currentAttr = $attrs;
+ }
+
+ /**
+ * Handle the end event of a tag while parsing
+ *
+ * @access private
+ * @param object the xmlParser object
+ * @param string name of currently ending tag
+ * @return void
+ */
+ private function endElement($parser, $tagName)
+ {
+ if (in_array($tagName, $this->itemTags))
+ {
+ $this->itemIndex++;
+ }
+
+ array_pop($this->insideItem);
+ $this->currentTag = $this->insideItem[count($this->insideItem)-1];
+ }
+
+ /**
+ * Handle character data of a tag while parsing
+ *
+ * @access private
+ * @param object the xmlParser object
+ * @param string tag value
+ * @return void
+ */
+ private function characterData($parser, $data)
+ {
+ //Converting all date formats to timestamp
+ if(in_array($this->currentTag, $this->dateTags))
+ {
+ $data = strtotime($data);
+ }
+
+ if($this->inChannel())
+ {
+ // If has subtag, make current element an array and assign subtags as it's element
+ if(in_array($this->getParentTag(), $this->hasSubTags))
+ {
+ if(! is_array($this->channels[$this->getParentTag()]))
+ {
+ $this->channels[$this->getParentTag()] = array();
+ }
+
+ $this->channels[$this->getParentTag()][$this->currentTag] .= strip_tags($this->unhtmlentities((trim($data))));
+ return;
+ }
+ else
+ {
+ if(! in_array($this->currentTag, $this->hasSubTags))
+ {
+ $this->channels[$this->currentTag] .= strip_tags($this->unhtmlentities((trim($data))));
+ }
+ }
+
+ if(!empty($this->currentAttr))
+ {
+ $this->channels[$this->currentTag . '_ATTRS'] = $this->currentAttr;
+
+ //If the tag has no value
+ if(strlen($this->channels[$this->currentTag]) < 2)
+ {
+ //If there is only one attribute, assign the attribute value as channel value
+ if(count($this->currentAttr) == 1)
+ {
+ foreach($this->currentAttr as $attrVal)
+ {
+ $this->channels[$this->currentTag] = $attrVal;
+ }
+ }
+ //If there are multiple attributes, assign the attributs array as channel value
+ else
+ {
+ $this->channels[$this->currentTag] = $this->currentAttr;
+ }
+ }
+ }
+ }
+ elseif($this->inItem())
+ {
+ // If has subtag, make current element an array and assign subtags as it's elements
+ if(in_array($this->getParentTag(), $this->hasSubTags))
+ {
+ if(! is_array($this->items[$this->itemIndex][$this->getParentTag()]))
+ {
+ $this->items[$this->itemIndex][$this->getParentTag()] = array();
+ }
+
+ $this->items[$this->itemIndex][$this->getParentTag()][$this->currentTag] .= strip_tags($this->unhtmlentities((trim($data))));
+ return;
+ }
+ else
+ {
+ if(! in_array($this->currentTag, $this->hasSubTags))
+ {
+ $this->items[$this->itemIndex][$this->currentTag] .= strip_tags($this->unhtmlentities((trim($data))));
+ }
+ }
+
+
+ if(!empty($this->currentAttr))
+ {
+ $this->items[$this->itemIndex][$this->currentTag . '_ATTRS'] = $this->currentAttr;
+
+ //If the tag has no value
+
+ if(strlen($this->items[$this->itemIndex][$this->currentTag]) < 2)
+ {
+ //If there is only one attribute, assign the attribute value as feed element's value
+ if(count($this->currentAttr) == 1)
+ {
+ foreach($this->currentAttr as $attrVal)
+ {
+ $this->items[$this->itemIndex][$this->currentTag] = $attrVal;
+ }
+ }
+ //If there are multiple attributes, assign the attribute array as feed element's value
+ else
+ {
+ $this->items[$this->itemIndex][$this->currentTag] = $this->currentAttr;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Find out the feed version
+ *
+ * @access private
+ * @param string name of current tag
+ * @param array array of attributes
+ * @return void
+ */
+ private function findVersion($tagName, $attrs)
+ {
+ $namespace = array_values($attrs);
+ foreach($this->namespaces as $value =>$version)
+ {
+ if(in_array($value, $namespace))
+ {
+ $this->version = $version;
+ return;
+ }
+ }
+ }
+
+ private function getParentTag()
+ {
+ return $this->insideItem[count($this->insideItem) - 2];
+ }
+
+ /**
+ * Detect if current position is in channel element
+ *
+ * @access private
+ * @return bool
+ */
+ private function inChannel()
+ {
+ if($this->version == 'RSS 1.0')
+ {
+ if(in_array('CHANNEL', $this->insideItem) && $this->currentTag != 'CHANNEL')
+ return TRUE;
+ }
+ elseif($this->version == 'RSS 2.0')
+ {
+ if(in_array('CHANNEL', $this->insideItem) && !in_array('ITEM', $this->insideItem) && $this->currentTag != 'CHANNEL')
+ return TRUE;
+ }
+ elseif($this->version == 'ATOM 1')
+ {
+ if(in_array('FEED', $this->insideItem) && !in_array('ENTRY', $this->insideItem) && $this->currentTag != 'FEED')
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ /**
+ * Detect if current position is in Item element
+ *
+ * @access private
+ * @return bool
+ */
+ private function inItem()
+ {
+ if($this->version == 'RSS 1.0' || $this->version == 'RSS 2.0')
+ {
+ if(in_array('ITEM', $this->insideItem) && $this->currentTag != 'ITEM')
+ return TRUE;
+ }
+ elseif($this->version == 'ATOM 1')
+ {
+ if(in_array('ENTRY', $this->insideItem) && $this->currentTag != 'ENTRY')
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ //This function is taken from lastRSS
+ /**
+ * Replace HTML entities &something; by real characters
+ *
+ *
+ * @access private
+ * @author Vojtech Semecky <web...@os...>
+ * @link http://lastrss.oslab.net/
+ * @param string
+ * @return string
+ */
+ private function unhtmlentities($string)
+ {
+ // Get HTML entities table
+ $trans_tbl = get_html_translation_table (HTML_ENTITIES, ENT_QUOTES);
+ // Flip keys<==>values
+ $trans_tbl = array_flip ($trans_tbl);
+ // Add support for ' entity (missing in HTML_ENTITIES)
+ $trans_tbl += array(''' => "'");
+ // Replace entities by values
+ return strtr ($string, $trans_tbl);
+ }
+} //End class FeedParser
+?>
Added: RMC/modules/xthemes/trunk/xthemes/class/xtfunctions.class.php
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/class/xtfunctions.class.php (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/class/xtfunctions.class.php 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1,156 @@
+<?php
+// $Id: xtfunctions.class.php 172 2012-12-13 06:17:41Z i.bitcero $
+// --------------------------------------------------------------
+// xThemes for XOOPS
+// Module for manage themes by Red Mexico
+// Author: Eduardo Cortés <i.b...@gm...>
+// License: GPL v2
+// --------------------------------------------------------------
+
+class XtFunctions
+{
+ public function toolbar(){
+ RMTemplate::get()->add_tool(__('Dashboard', 'xthemes'), 'index.php', 'images/dashboard.png', 'dashboard');
+ RMTemplate::get()->add_tool(__('Available Themes', 'xthemes'), 'themes.php', 'images/themes.png', 'catalog');
+ RMTemplate::get()->add_tool(__('Theme Settings', 'xthemes'), 'settings.php', 'images/settings.png', 'settings');
+ RMTemplate::get()->add_tool(__('About', 'xthemes'), 'index.php?action=about', 'images/about.png', 'about');
+ $events = RMEvents::get();
+ $events->run_event('xthemes.toolbar');
+ }
+
+ /**
+ * @deprecated
+ */
+ public function menu_options(){
+ $this->toolbar();
+ }
+
+ /**
+ * Get the current theme and all related information
+ * return object
+ */
+ public function current_theme(){
+ global $xoopsConfig;
+
+ // Configured theme
+ $ctheme = $xoopsConfig['theme_set'];
+
+ // Check if theme is a valid xTheme or not
+ $theme = $this->load_theme($ctheme);
+
+ return $theme;
+
+ }
+
+ /**
+ * Load a specified theme
+ * return object
+ */
+ public function load_theme($dir){
+
+ if($dir=='') return false;
+
+ $fulldir = XOOPS_THEME_PATH.'/'.$dir;
+ if(!is_dir($fulldir)) return false;
+
+ $theme_file = $fulldir.'/assemble/'.$dir.'.theme.php';
+
+ if(is_file($theme_file)){
+ include_once $theme_file;
+ $class = ucfirst($dir);
+ $theme = new $class();
+ return $theme;
+ }
+
+ $theme = new StandardTheme();
+ $theme->set_dir($dir);
+ return $theme;
+
+ }
+
+ /**
+ * Insert configuration options
+ * @param array with sections and options
+ * @return bool
+ */
+ public function insertOptions($theme, $set = null){
+
+ if($theme==null) return false;
+ $options = $theme->options();
+
+ if(empty($options)) return true;
+
+ $db = XoopsDatabaseFactory::getDatabaseConnection();
+ // Current settings
+ $current = $theme->settings();
+ $count = count($current);
+
+ $sql = "INSERT INTO ".$db->prefix("xt_options")." (`theme`,`name`,`value`,`type`) VALUES ";
+ $sqlu = "UPDATE ".$db->prefix("xt_options")." SET `value`=";
+
+ foreach($options['options'] as $name => $option){
+ if($count<=0){
+ $value = isset($set[$name]) ? $set[$name] : $option['default'];
+ $value = $option['type']=='array' ? serialize($value) : TextCleaner::getInstance()->addslashes($value);
+ $values[] = "(".$theme->id().",'$name','$value','$option[content]')";
+ }else {
+ if($set && isset($current[$name]) && isset($set[$name])){
+ // Update single option
+ $value = $option['content']=='array' ? serialize($set[$name]) : TextCleaner::getInstance()->addslashes($set[$name]);
+ $sqlt = $sqlu . "'$value', `type`='$option[content]' WHERE name='$name' AND theme='".$theme->id()."'";
+ $db->queryF($sqlt);
+ }else{
+ $value = isset($set[$name]) ? $set[$name] : $option['content'];
+ $value = $option['type']=='array' ? serialize($value) : TextCleaner::getInstance()->addslashes($value);
+ $values[] = "(".$theme->id().",'$name','$value','$option[content]')";
+ }
+ }
+
+ }
+
+ if(!empty($values))
+ $sql .= implode(",",$values);
+ else
+ return true;
+
+ return $db->queryF($sql);
+
+ }
+
+ /**
+ * Remove all theme data from database
+ */
+ public function purge_theme($theme){
+
+ if(!$theme) return false;
+ if(is_a($theme, 'StandardTheme')) return true;
+
+ // Delete options
+ $db = XoopsDatabaseFactory::getDatabaseConnection();
+ $sql = "DELETE FROM ".$db->prefix("xt_options")." WHERE theme=".$theme->id();
+ if(!$db->queryF($sql))
+ return false;
+
+ $sql = "DELETE FROM ".$db->prefix("xt_menus")." WHERE theme=".$theme->id();
+ if(!$db->queryF($sql))
+ return false;
+
+ return $theme->delete();
+
+ }
+
+ /**
+ * Forms the menu in menu manager based on <li>s
+ * @param
+ */
+ public function formAdminMenu($menu){
+ if(empty($menu)) return false;
+
+ $tpl = RMTemplate::get();
+
+ foreach($menu as $m){
+ include $tpl->get_template('xt_menu_manager.php', 'module', 'xthemes');
+ }
+ }
+
+}
Added: RMC/modules/xthemes/trunk/xthemes/class/xttheme.php
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/class/xttheme.php (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/class/xttheme.php 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1,158 @@
+<?php
+// $Id: xttheme.php 99 2012-10-24 21:46:58Z i.bitcero $
+// --------------------------------------------------------------
+// xThemes for XOOPS
+// Module for manage themes by Red Mexico
+// Author: Eduardo Cortés <i.b...@gm...>
+// License: GPL v2
+// --------------------------------------------------------------
+
+/**
+* This is the plugins parent class
+*/
+
+abstract class XtTheme extends RMObject
+{
+ protected $details = array();
+ protected $errors = array();
+ private $settings = array();
+
+ /**
+ * Load a theme
+ *
+ * @param mixed Id or dirname for theme
+ * @return XtTheme
+ */
+ public function __construct(){
+ // Load details from theme
+ $this->details = $this->details();
+
+ $this->db = XoopsDatabaseFactory::getDatabaseConnection();
+ $this->_dbtable = $this->db->prefix("xt_themes");
+ $this->setNew();
+ $this->initVarsFromTable();
+
+ $id = $this->getInfo('dir');
+ $this->primary = 'dir';
+ if ($this->loadValues($id)) $this->unsetNew();
+ $this->primary = 'id_theme';
+
+ if($this->isNew()){
+ $this->setVars($this->getInfo());
+ }
+
+ }
+
+ public function errors(){
+ return $this->errors;
+ }
+
+ /**
+ * Get an info key or all information
+ */
+ public function getInfo($key = ''){
+
+ if($key=='') return $this->details;
+
+ if(!isset($this->details[$key])) return false;
+ return $this->details[$key];
+
+ }
+
+ /**
+ * Get theme url
+ * @return string
+ */
+ public function url(){
+ return XOOPS_THEME_URL.'/'.$this->getInfo('dir');
+ }
+ /**
+ * Get theme path
+ * @return string
+ */
+ public function path(){
+ return XOOPS_THEME_PATH.'/'.$this->getInfo('dir');
+ }
+
+ /**
+ * Indicates if theme is installed
+ * @return bool
+ */
+ public function installed(){
+ global $xtAssembler;
+
+ return $xtAssembler->theme()->getInfo('dir')==$this->getInfo('dir');
+ }
+
+ public function on_install(){
+ return true;
+ }
+
+ public function on_uninstall(){
+ return true;
+ }
+
+ public function setSettings($settings){
+ $this->settings = $settings;
+ }
+
+ /**
+ * Get theme configuration
+ */
+ public function settings($key = ''){
+ if($key=='') return $this->settings;
+
+ if(isset($this->settings[$key]))
+ return $this->settings[$key];
+
+ return false;
+ }
+
+ /**
+ * This function allows to themes verify the input data for each individual setting
+ * @param mixed $value
+ * @return mixed value
+ */
+ public function checkSettingValue($value){
+ return $value;
+ }
+
+ public function save(){
+ if($this->isNew())
+ return $this->saveToTable();
+ else
+ return $this->updateTable();
+ }
+
+ public function delete(){
+ return $this->deleteFromTable();
+ }
+
+ public function menu($id=''){
+ global $xtAssembler;
+ return $xtAssembler->menu($id);
+ }
+
+}
+
+interface XtITheme
+{
+ public function details();
+
+ /**
+ * This function must return a name for menu(s) (if supported)
+ * otherwise must return false
+ * @return string with menu name
+ * @return array with menus names
+ */
+ public function haveMenus();
+ /**
+ * Get configuration options with default values
+ * @return array
+ */
+ public function options();
+ /**
+ * This event is launched when xtAssembler init basic smarty vars
+ */
+ public function init();
+}
Added: RMC/modules/xthemes/trunk/xthemes/css/dashboard.css
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/css/dashboard.css (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/css/dashboard.css 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1,145 @@
+/*
+$Id: dashboard.css 101 2012-10-25 06:12:22Z i.bitcero $
+*/
+
+.xt_left{
+ padding: 0 10px 0 0;
+ float: left;
+ width: 55%;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -o-box-sizing: border-box;
+}
+.xt_right{
+ padding: 0 0 0 10px;
+ float: left;
+ width: 45%;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -o-box-sizing: border-box;
+}
+
+/* NEWS
+==========================================*/
+.news_item{
+ padding: 10px 0;
+ border-bottom: 1px solid #CCC;
+ color: #666;
+}
+.news_item:last-child{
+ border-bottom: 0;
+}
+.news_item:after{
+ content: '';
+ display: block;
+ height: 1px;
+ clear: both;
+}
+.news_item > h3{
+ padding: 0;
+ margin: 0 0 10px 0;
+ font-size: 14px;
+ text-transform: uppercase;
+}
+.news_item > a.thumb > img{
+ width: 70px;
+ float: left;
+}
+.news_item > .news_content{
+ display: block;
+ margin-left: 90px;
+}
+.news_item > .link{
+ display: block;
+ margin-left: 90px;
+}
+#xthemes-credits ul{
+ list-style: none;
+ padding: 0;
+ margin: 0;
+}
+#xthemes-credits ul > li{
+ list-style: none;
+ padding: 3px 0;
+}
+#xthemes-credits ul > li > span{
+ display: inline-block;
+ vertical-align: text-bottom;
+ width: 80px;
+ font-weight: bold;
+}
+
+.dtitem{
+ padding: 10px;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -o-box-sizing: border-box;
+ width: 180px;
+ height: 180px;
+ display: inline-block;
+ vertical-align: text-top;
+ position: relative;
+}
+#recent-themes{
+ overflow: hidden;
+ height: 180px;
+ text-align: center;
+}
+#recent-themes:after{
+ content: '';
+ display: block;
+ height: 1px;
+ clear: both;
+}
+.dtitem > a{
+ width: 100%;
+ height: 100%;
+ border: 1px solid #CCC;
+ display: block;
+ position: relative;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -o-box-sizing: border-box;
+ background-position: center;
+ background-repeat: no-repeat;
+ background-size: 100%;
+}
+.dtitem > a > .name{
+ display: block;
+ text-align: center;
+ position: absolute;
+ bottom: 0; left: 0; right: 0;
+ padding: 5px;
+ background: #000;
+ color: #FFF;
+ opacity: 0.7;
+ text-shadow: 1px 1px 1px #000;
+}
+.dtitem > .desc{
+ display: none;
+}
+.themes{
+ margin-bottom: 15px;
+}
+.waiting{
+ background: url(../images/searching.gif) no-repeat center;
+ min-height: 100px;
+}
+.empty{
+ background: url(../images/error.png) no-repeat center;
+ min-height: 100px;
+}
+.info-box{
+ background: #FFF8D6;
+ border: 1px solid #FFC464;
+ border-radius: 3px;
+ padding: 10px;
+ margin-top: 15px;
+}
+.info-box p{
+ margin-bottom: 10px;
+}
\ No newline at end of file
Added: RMC/modules/xthemes/trunk/xthemes/css/index.html
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/css/index.html (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/css/index.html 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1 @@
+ <script>history.go(-1);</script>
\ No newline at end of file
Added: RMC/modules/xthemes/trunk/xthemes/css/settings.css
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/css/settings.css (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/css/settings.css 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1,103 @@
+/*
+$Id: settings.css 159 2012-12-06 23:51:54Z i.bitcero $
+*/
+
+.w_sections{
+ list-style: none;
+ padding: 0px;
+ margin: 0;
+ /*position: absolute;*/
+ top: 0; left: 0; bottom: 0; right: 0;
+}
+.w_sections li{
+ list-style: none;
+ margin: 0 0 1px 0;
+ background: #ebebeb url("../images/a-left.png") no-repeat -50px;
+ transition: all 0.3s linear;
+ -moz-transition: all 0.3s linear;
+ -webkit-transition: all 0.3s linear;
+ -o-transition: all 0.3s linear;
+}
+/*.w_sections li:first-child{border-radius: 3px 3px 0 0;}*/
+.w_sections li:last-child{border-radius: 0 0 3px 3px;}
+.w_sections li a{
+ display: block;
+ padding: 10px 12px;
+ text-transform: uppercase;
+ color: #666;
+ background: url("../images/a-right.png") no-repeat 120%;
+ text-shadow: 1px 1px 0 #fafafa;
+ transition: all 0.5s linear;
+ -moz-transition: all 0.5s linear;
+ -webkit-transition: all 0.5s linear;
+ -o-transition: all 0.5s linear;
+}
+.w_sections li:hover{
+ background-position: left;
+ background-color: #8CD3FF;
+}
+.w_sections li:hover a{
+ /*background-position: right;*/
+ text-decoration: none;
+ color: #FFF;
+ text-shadow: 1px 1px 0 #66B1E0;
+}
+.w_sections li.xt-section-visible{
+ background-color: #FF9B3F;
+ background-position: left;
+}
+.w_sections li.xt-section-visible a{
+ color: #663E19;
+ text-shadow: 1px 1px 0 #FFC896;
+ font-weight: bold;
+ text-align: center;
+ background: url("../images/a-right.png") no-repeat right;
+ cursor: default;
+}
+
+/* Sections */
+.xt-configuration-section{
+ display: none;
+}
+.xt-option-group{
+ padding: 10px 0;
+ border-bottom: 1px dotted #ddd;
+}
+.xt-option-label{
+ font-weight: bold;
+ padding: 0;
+ display: inline-block;
+ line-height: 80%;
+}
+.xt-option-field{
+ display: block;
+ padding: 2px 0;
+}
+.xt-option-desc{
+ display: block;
+ line-height: 150%;
+ color: #666;
+ padding: 2px 0;
+ font-size: 0.9em;
+}
+
+.xt-settings-buttons{
+ overflow: hidden;
+ display: table;
+}
+.xt-settings-buttons > div{
+ display: table-row;
+}
+.xt-settings-buttons > div > div:last-child{
+ width: 250px;
+ display: table-cell;
+ padding: 0 0 0 5px;
+ text-align: right;
+ vertical-align: middle;
+}
+.sb-bottom{
+ margin-top: 10px;
+}
+.control-group{
+ border-bottom: 1px dashed #d4d4d4;
+}
Added: RMC/modules/xthemes/trunk/xthemes/css/themes.css
===================================================================
--- RMC/modules/xthemes/trunk/xthemes/css/themes.css (rev 0)
+++ RMC/modules/xthemes/trunk/xthemes/css/themes.css 2013-02-12 02:08:36 UTC (rev 11029)
@@ -0,0 +1,452 @@
+/*
+$Id: themes.css 159 2012-12-06 23:51:54Z i.bitcero $
+*/
+
+.xt-separator{
+ clear: both;
+ display: block;
+ ...
[truncated message content] |