コード例 #1
0
ファイル: nova.php プロジェクト: sayedwp/supernova
 function nova_filtered_url()
 {
     $config = apply_filters('nova/config', array());
     if (isset($config['url_path'])) {
         Nova::$url = esc_url_raw($config['url_path']);
     }
 }
コード例 #2
0
/**
 * MissionCaseStayAlly @todo description
 *
 * @global array $lang @see common.php
 * @param array $fleetRow @see common.php
 * @return bool true.
 */
function missionCaseStayAlly($fleetRow)
{
    global $lang;
    $readConnection = Nova::getSingleton('core/database_connection_pool')->getConnection('core_read');
    $startPlanet = $readConnection->select(array('name', 'id_owner'))->from($readConnection->getDeprecatedTable('planets'))->where('galaxy =?', $fleetRow['fleet_start_galaxy'])->where('system =?', $fleetRow['fleet_start_system'])->where('planet =?', $fleetRow['fleet_start_planet'])->query()->fetch();
    $endPlanet = $readConnection->select(array('name', 'id_owner'))->from($readConnection->getDeprecatedTable('planets'))->where('galaxy =?', $fleetRow['fleet_end_galaxy'])->where('system =?', $fleetRow['fleet_end_system'])->where('planet =?', $fleetRow['fleet_end_planet'])->query()->fetch();
    $fleetStartLink = GetStartAdressLink($fleetRow, '');
    $fleetEndLink = GetTargetAdressLink($fleetRow, '');
    if ($fleetRow['fleet_mess'] == 0) {
        if ($fleetRow['fleet_end_stay'] <= time()) {
            $readConnection->update($readConnection->getDeprecatedTable('fleets'), array('fleet_mess' => 1), array('fleet_id =?' => $fleetRow['fleet_id']));
        } else {
            if ($fleetRow['fleet_start_time'] <= time()) {
                $message = sprintf($lang['sys_tran_mess_owner'], $endPlanet['name'], $fleetEndLink, $fleetRow['fleet_resource_metal'], $lang['Metal'], $fleetRow['fleet_resource_crystal'], $lang['Crystal'], $fleetRow['fleet_resource_deuterium'], $lang['Deuterium']);
                SendSimpleMessage($startPlanet['id_owner'], '', $fleetRow['fleet_start_time'], 5, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $message);
                $message = sprintf($lang['sys_tran_mess_user'], $startPlanet['name'], $fleetStartLink, $endPlanet['name'], $fleetEndLink, $fleetRow['fleet_resource_metal'], $lang['Metal'], $fleetRow['fleet_resource_crystal'], $lang['Crystal'], $fleetRow['fleet_resource_deuterium'], $lang['Deuterium']);
                SendSimpleMessage($endPlanet['id_owner'], '', $fleetRow['fleet_start_time'], 5, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $message);
            }
        }
    } else {
        if ($fleetRow['fleet_end_time'] <= time()) {
            $message = sprintf($lang['sys_tran_mess_back'], $startPlanet['name'], $fleetStartLink);
            SendSimpleMessage($startPlanet['id_owner'], '', $fleetRow['fleet_end_time'], 5, $lang['sys_mess_tower'], $lang['sys_mess_fleetback'], $message);
            RestoreFleetToPlanet($fleetRow, true);
            $readConnection->delete($readConnection->getDeprecatedTable('fleets'), array('fleet_id =?' => $fleetRow['fleet_id']));
        }
    }
    return true;
}
コード例 #3
0
 /**
  * TODO: PHPDoc
  *
  * @return Nova_User_Model_Entity
  */
 protected function _getUser()
 {
     if (is_null($this->_userModel)) {
         $this->_userModel = Nova::getSingleton('user/session')->getUser();
     }
     return $this->_userModel;
 }
コード例 #4
0
ファイル: Database.php プロジェクト: sonicmaster/RPG
 /**
  * @deprecated
  * @return unknown_type
  */
 public static function getInstance()
 {
     if (is_null(self::$_defaultConnection)) {
         self::$_defaultConnection = Nova::getModel('core/database_connection_pool')->getConnection('core_read');
     }
     return self::$_defaultConnection;
 }
コード例 #5
0
ファイル: Session.php プロジェクト: sonicmaster/RPG
 /**
  * Returns the contents of storage
  *
  * Behavior is undefined when storage is empty.
  *
  * @see Zend_Auth_Storage
  * @throws Zend_Auth_Storage_Exception If reading contents from storage is impossible
  * @return mixed
  */
 public function read()
 {
     if ($this->isEmpty()) {
         // TODO: I18n
         Nova::throwException('user/authStorageAccessError', 'User account storage is empty');
     }
     // TODO: implement logic
 }
コード例 #6
0
 /**
  * Process fields added using the 'nova/fields' and 'nova/controls' filter.
  * These filters are no longer used, this is simply for backwards-compatibility
  */
 public function fields_from_filters()
 {
     $fields = apply_filters('nova/controls', array());
     $fields = apply_filters('nova/fields', $fields);
     if (!empty($fields)) {
         foreach ($fields as $field) {
             Nova::add_field('global', $field);
         }
     }
 }
コード例 #7
0
ファイル: settings.php プロジェクト: sonicmaster/RPG
function DisplayGameSettingsPage()
{
    global $lang, $game_config;
    includeLang('admin/settings');
    if ($_POST) {
        $game_config_keys = array_keys($game_config);
        $game_config_old = $game_config;
        foreach ($_POST as $key => $value) {
            if (in_array($key, $game_config_keys)) {
                $key = mysql_real_escape_string($key);
                $value = mysql_real_escape_string($value);
                $game_config[$key] = $value == 'on' ? '1' : $value;
            }
        }
        $checkboxArray = array('game_disable', 'OverviewNewsFrame', 'OverviewExternChat', 'OverviewBanner', 'debug');
        foreach ($checkboxArray as $checkbox) {
            if (is_null($_POST[$checkbox])) {
                $game_config[$checkbox] = '0';
            }
        }
        $game_config_newValues = array_diff_assoc($game_config, $game_config_old);
        $readConnection = Nova::getSingleton('core/database_connection_pool')->getConnection('core_read');
        foreach ($game_config_newValues as $key => $value) {
            $readConnection->update($readConnection->getDeprecatedTable('config'), array('config_value' => $value), array('config_name =?' => $key));
        }
        AdminMessage($lang['GameSettings_SettingsChanged'], $lang['GameSettings_Success']);
    } else {
        $parse = $lang;
        foreach ($game_config as $key => $value) {
            $parse[$key] = $value;
        }
        $parse['closed'] = $game_config['game_disable'] == 1 ? " checked = 'checked' " : "";
        $parse['newsframe'] = $game_config['OverviewNewsFrame'] == 1 ? " checked = 'checked' " : "";
        $parse['chatframe'] = $game_config['OverviewExternChat'] == 1 ? " checked = 'checked' " : "";
        $parse['googlead'] = $game_config['OverviewBanner'] == 1 ? " checked = 'checked' " : "";
        $parse['debug'] = $game_config['debug'] == 1 ? " checked = 'checked' " : "";
        $parse['bannerframe'] = $game_config['ForumBannerFrame'] == 1 ? " checked = 'checked' " : "";
        $PageTPL = gettemplate('admin/options_body');
        $Page = parsetemplate($PageTPL, $parse);
        display($Page, $lang['GameSettings_Title'], false, '', true);
    }
    return $Page;
}
コード例 #8
0
ファイル: AccountController.php プロジェクト: sonicmaster/RPG
 /**
  *
  *
  */
 public function loginPostAction()
 {
     $this->_requireLogoff();
     if (!$this->getRequest()->isPost()) {
         $this->_redirectError('user/login');
         return;
     }
     $fields = Nova::getFieldset('user_login');
     $formData = array();
     foreach ($fields as $fieldName => $fieldConfig) {
         $value = $this->getRequest()->getPost($fieldName, null);
         if (is_null($value) || empty($value)) {
             $this->redirectError('user/login');
             return;
         }
         $formData[$fieldName] = $value;
     }
     Nova::getModel('user/');
     // FIXME
     $this->_redirectSuccess('user');
 }
コード例 #9
0
ファイル: Entity.php プロジェクト: sonicmaster/RPG
 public function login($identity, $credential, $salt)
 {
     // TODO: dispatch event 'user.login.before'
     if ($this->isLoaded()) {
         return false;
     }
     $adapter = Nova::getModel('user/entity.authentication.adapter.password-stealth')->setIdentity($identity)->setCredential($credential)->setSalt($salt);
     $storage = Nova::getSingleton('user/session')->setUserModel($this);
     $result = Zend_Auth::getInstance()->setStorage($storage)->authenticate($adapter);
     var_dump($result);
     // TODO: dispatch event 'user.login.after'
     switch ($result->getCode()) {
         case Zend_Auth_Result::SUCCESS:
             // TODO: dispatch event 'user.login.success'
             $this->load($result->getIdentity(), 'username');
             return true;
         case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
             // TODO: I18n
             Nova::getSingleton('user/session')->addNotice('Wrong password.');
             break;
         case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS:
         case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
             // TODO: I18n
             Nova::getSingleton('user/session')->addNotice('User does not exist.');
             break;
         case Zend_Auth_Result::FAILURE_UNCATEGORIZED:
         default:
             // TODO: I18n
             Nova::getSingleton('user/session')->addError('Could not connect, an error occured. Please contact admin.');
             break;
     }
     foreach ($result->getMessages() as $message) {
         Nova::getSingleton('user/session')->addNotice($message);
     }
     // TODO: dispatch event 'user.login.failure'
     return false;
 }
コード例 #10
0
ファイル: AdapterAbstract.php プロジェクト: sonicmaster/RPG
 /**
  * FIXME PHPDoc
  *
  * @return Nova_Core_Bo_EntityAbstract
  */
 public function getAuthenticationModel()
 {
     if (is_null($this->_authenticationModel)) {
         $this->_authenticationModel = Nova::getModel('user/entity.authentication');
     }
     return $this->_authenticationModel;
 }
コード例 #11
0
ファイル: bootstrap.php プロジェクト: sonicmaster/RPG
 */
session_start();
/**
 * Set up environment
 */
defined('DEBUG') || define('DEBUG', ($env = strtolower(getenv('DEBUG'))) === '1' || $env === 'true' || $env === 'on');
defined('DEPRECATION') || define('DEPRECATION', ($env = strtolower(getenv('DEPRECATION'))) === '1' || $env === 'true' || $env === 'on');
/**
 * Define a valid include_path
 */
set_include_path(implode(PS, array(ROOT_PATH . 'library', APPLICATION_PATH . 'code' . DS . 'core', APPLICATION_PATH . 'code' . DS . 'community', APPLICATION_PATH . 'code' . DS . 'local')));
require_once 'Nova.php';
/**
 * Zend Framework's autoloader class.
 * @todo: add this to Nova::app()
 */
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('Legacies_');
$loader->registerNamespace('Nova_');
$loader->registerNamespace('Whitewashing_');
/**
 * Check up if the game is already installed.
 */
if (!file_exists(APPLICATION_PATH . 'config/local.xml')) {
    header('HTTP/1.1 302 Found');
    header('Location: install/');
    exit(0);
}
Nova::app()->bootstrap()->run();
コード例 #12
0
/**
 * Create a new planet and insert it on the database
 * 
 * @param int|string $galaxy
 * @param int|string $system
 * @param int|string $position
 * @param int|string $planetOwnerId
 * @param string $planetName
 * @param bool $homeWorld
 * 
 * @return bool
 */
function CreateOnePlanetRecord($galaxy, $system, $position, $planetOwnerId, $planetName = '', $homeWorld = false)
{
    global $lang, $game_config;
    /**
     * @var resource Get database link
     */
    $readConnection = Nova::getSingleton('core/database_connection_pool')->getConnection('core_read');
    $planetExist = $readConnection->select()->from($readConnection->getDeprecatedTable('planets'))->where('galaxy =?', $galaxy)->where('system =?', $system)->where('planet =?', $position)->query()->fetch();
    if (!$planetExist) {
        $planet = PlanetSizeRandomiser($position, $homeWorld);
        $planet['metal'] = BUILD_METAL;
        $planet['crystal'] = BUILD_CRISTAL;
        $planet['deuterium'] = BUILD_DEUTERIUM;
        $planet['metal_perhour'] = $game_config['metal_basic_income'];
        $planet['crystal_perhour'] = $game_config['crystal_basic_income'];
        $planet['deuterium_perhour'] = $game_config['deuterium_basic_income'];
        $planet['metal_max'] = BASE_STORAGE_SIZE;
        $planet['crystal_max'] = BASE_STORAGE_SIZE;
        $planet['deuterium_max'] = BASE_STORAGE_SIZE;
        $planet['galaxy'] = $galaxy;
        $planet['system'] = $system;
        $planet['planet'] = $position;
        if ($position == 1 || $position == 2 || $position == 3) {
            $planetType = 'trocken';
            $planetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10');
            $planet['temp_min'] = rand(0, 100);
            $planet['temp_max'] = $planet['temp_min'] + 40;
        } elseif ($position == 4 || $position == 5 || $position == 6) {
            $planetType = 'dschjungel';
            $planetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10');
            $planet['temp_min'] = rand(-25, 75);
            $planet['temp_max'] = $planet['temp_min'] + 40;
        } elseif ($position == 7 || $position == 8 || $position == 9) {
            $planetType = 'normaltemp';
            $planetDesign = array('01', '02', '03', '04', '05', '06', '07');
            $planet['temp_min'] = rand(-50, 50);
            $planet['temp_max'] = $planet['temp_min'] + 40;
        } elseif ($position == 10 || $position == 11 || $position == 12) {
            $planetType = 'wasser';
            $planetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09');
            $planet['temp_min'] = rand(-75, 25);
            $planet['temp_max'] = $planet['temp_min'] + 40;
        } elseif ($position == 13 || $position == 14 || $position == 15) {
            $planetType = 'eis';
            $planetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10');
            $planet['temp_min'] = rand(-100, 10);
            $planet['temp_max'] = $planet['temp_min'] + 40;
        } else {
            $planetType = 'wuesten';
            $planetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '00');
            $planet['temp_min'] = rand(-120, 10);
            $planet['temp_max'] = $planet['temp_min'] + 40;
        }
        $planet['image'] = $planetType . 'planet' . $planetDesign[rand(0, count($planetDesign) - 1)];
        $planet['planet_type'] = 1;
        $planet['id_owner'] = $planetOwnerId;
        $planet['last_update'] = new Zend_Db_Expr('UNIX_TIMESTAMP()');
        $planet['name'] = $planetName == '' ? $lang['sys_colo_defaultname'] : $planetName;
        $readConnection->insert($readConnection->getDeprecatedTable('planets'), $planet);
        $planetId = $readConnection->lastInsertId($readConnection->getDeprecatedTable('planets'));
        $galaxyPosition = $readConnection->select()->from($readConnection->getDeprecatedTable('galaxy'), array('id' => 'id_planet'))->where('galaxy=?', $galaxy)->where('system=?', $system)->where('planet=?', $position)->query()->fetch();
        if ($galaxyPosition) {
            $readConnection->update($readConnection->getDeprecatedTable('galaxy'), array('id_planet' => $planetId), array('id_planet =?', $galaxyPosition['id']));
        } else {
            $data = array('galaxy' => $planet['galaxy'], 'system' => $planet['system'], 'planet' => $planet['planet'], 'id_planet' => $planetId);
            $readConnection->insert($readConnection->getDeprecatedTable('galaxy'), $data);
        }
        return $planetId;
    } else {
        return false;
    }
}
コード例 #13
0
ファイル: Nova.php プロジェクト: sonicmaster/RPG
 /**
  *
  * @return unknown_type
  *
  * FIXME : Reimplemet method
  */
 public static function app()
 {
     if (is_null(self::$_application)) {
         self::$_application = new Nova_Core_Model_Application();
     }
     return self::$_application;
 }
コード例 #14
0
 /**
  * Returns the selected endpoint URL of this compute Service
  *
  * @param string $resource - an optional child resource. For example,
  *      passing 'details' would return .../servers/details. Should *not* be
  *    prefixed with a slash (/).
  * @param array $args (optional) an array of key-value pairs for query
  *      strings to append to the URL
  * @returns string - the requested URL
  */
 public function Url($resource = 'servers', $args = array())
 {
     return parent::Url($resource, $args);
 }
コード例 #15
0
ファイル: login.php プロジェクト: sonicmaster/RPG
    if ($login['banaday'] <= time() & $login['banaday'] != '0') {
        doquery("UPDATE {{table}} SET `banaday` = '0', `bana` = '0', `urlaubs_modus` ='0'  WHERE `username` = '{$login['username']}' LIMIT 1", 'users');
        doquery("DELETE FROM {{table}} WHERE `who` = '{$login['username']}'", 'banned');
    }
    if ($login) {
        if (intval($login['login_success'])) {
            if (isset($_POST["rememberme"])) {
                setCookie('nova-cookie', serialize(array('id' => $login['id'], 'key' => $login['login_rememberme'])), time() + 2592000);
            }
            $sql = <<<EOF
UPDATE {{table}} AS users
  SET users.onlinetime=UNIX_TIMESTAMP()
  WHERE users.id={$login['id']}
EOF;
            doquery($sql, 'users');
            Nova::getSingleton('user/session')->setUserId($login['id']);
            $_SESSION['user_id'] = $login['id'];
            header("Location: frames.php");
            exit(0);
        } else {
            message($lang['Login_FailPassword'], $lang['Login_Error']);
        }
    } else {
        message($lang['Login_FailUser'], $lang['Login_Error']);
    }
} else {
    $parse = $lang;
    $Count = doquery('SELECT COUNT(DISTINCT users.id) AS `players` FROM {{table}} AS users WHERE users.authlevel < 3', 'users', true);
    $LastPlayer = doquery('SELECT users.`username` FROM {{table}} AS users ORDER BY `register_time` DESC LIMIT 1', 'users', true);
    $parse['last_user'] = $LastPlayer['username'];
    $PlayersOnline = doquery("SELECT COUNT(DISTINCT id) AS `onlinenow` FROM {{table}} AS users WHERE `onlinetime` > (UNIX_TIMESTAMP()-900) AND users.authlevel < 3", 'users', true);
コード例 #16
0
 /**
  * creates the VolumeService object
  */
 public function __construct(OpenStack $conn, $name, $region, $urltype)
 {
     parent::__construct($conn, 'volume', $name, $region, $urltype);
 }
コード例 #17
0
ファイル: common.php プロジェクト: sonicmaster/RPG
$lang = array();
$IsUserChecked = false;
define('DEFAULT_SKINPATH', 'skins/xnova/');
define('TEMPLATE_DIR', realpath(ROOT_PATH . '/templates/'));
define('TEMPLATE_NAME', 'OpenGame');
define('DEFAULT_LANG', 'fr_FR');
$debug = Nova::getSingleton('core/debug');
include ROOT_PATH . 'includes/constants.php';
include ROOT_PATH . 'includes/functions.php';
include ROOT_PATH . 'includes/unlocalised.php';
include ROOT_PATH . 'includes/todofleetcontrol.php';
include ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg';
include ROOT_PATH . 'includes/vars.php';
include ROOT_PATH . 'db/mysql.php';
include ROOT_PATH . 'includes/strings.php';
$readConnection = Nova::getSingleton('core/database_connection_pool')->getConnection('core_read');
if (!defined('DISABLE_IDENTITY_CHECK')) {
    //$Result        = CheckTheUser($IsUserChecked);
    //$IsUserChecked = $Result['state'];
    //$user          = $Result['record'];
    if ($game_config['game_disable'] && $user->getAuthlevel() < 2) {
        message(stripslashes($game_config['close_reason']), $game_config['game_name']);
    }
}
includeLang('system');
includeLang('tech');
if (!$user->getId() && !defined('DISABLE_IDENTITY_CHECK')) {
    header('HTTP/1.1 401 Unauthorized');
    header('Location: login.php');
    exit(0);
}
コード例 #18
0
ファイル: deprecated.php プロジェクト: sayedwp/supernova
 /**
  * Get the value of a field.
  * This is a deprecated function that we in use when there was no API.
  * Please use the Nova::get_option() method instead.
  * Documentation is available for the new method on https://github.com/aristath/nova/wiki/Getting-the-values
  *
  * @return mixed
  */
 function nova_get_option($option = '')
 {
     return Nova::get_option('', $option);
 }
コード例 #19
0
 public static function add_field($config_id, $args)
 {
     if (is_array($config_id) && empty($args)) {
         $args = $config_id;
         $config_id = 'global';
     }
     $config_id = '' == $config_id ? 'global' : $config_id;
     /**
      * Get the configuration options
      */
     if (!isset(Nova::$config[$config_id])) {
         $config_id = 'global';
     }
     $config = Nova::$config[$config_id];
     /**
      * If we've set an option in the configuration
      * then make sure we're using options and not theme_mods
      */
     if ('' != $config['option_name']) {
         $config['option_type'] = 'option';
     }
     /**
      * If no option name has been set for the field,
      * use the one from the configuration
      */
     if (!isset($args['option_name'])) {
         $args['option_name'] = $config['option_name'];
     }
     /**
      * If no capability has been set for the field,
      * use the one from the configuration
      */
     if (!isset($args['capability'])) {
         $args['capability'] = $config['capability'];
     }
     /**
      * Check if [settings] is set.
      * If not set, check for [setting]
      */
     if (!isset($args['settings']) && isset($args['setting'])) {
         $args['settings'] = $args['setting'];
     }
     /**
      * If no option-type has been set for the field,
      * use the one from the configuration
      */
     if (!isset($args['option_type'])) {
         $args['option_type'] = $config['option_type'];
     }
     /**
      * Add the field to the static $fields variable properly indexed
      */
     Nova::$fields[Nova_Field_Sanitize::sanitize_settings($args)] = $args;
     if ('background' == $args['type']) {
         /**
          * Build the background fields
          */
         Nova::$fields = Nova_Explode_Background_Field::process_fields(Nova::$fields);
     }
 }
コード例 #20
0
 /**
  * Returns a list of flavors
  *
  * just call the parent FlavorList() method, but pass FALSE
  * because the /flavors/detail resource is not supported
  *
  * @api
  * @return \OpenCloud\Compute\FlavorList
  */
 public function FlavorList($details = FALSE, $filter = array())
 {
     return parent::FlavorList(FALSE);
 }
コード例 #21
0
ファイル: index.php プロジェクト: sonicmaster/RPG
require 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('Legacies_');
/**
 * @deprecated
 * @todo
 */
//{{{
define('PHPEXT', include ROOT_PATH . 'extension.inc');
define('DEFAULT_SKINPATH', '../skins/xnova/');
define('TEMPLATE_DIR', realpath(ROOT_PATH . '/templates/'));
define('TEMPLATE_NAME', 'OpenGame');
define('DEFAULT_LANG', 'fr_FR');
$dpath = DEFAULT_SKINPATH;
//}}}
$debug = Nova::getSingleton('core/debug');
/**
 * @deprecated
 */
// {{{
include ROOT_PATH . 'includes/constants.' . PHPEXT;
include ROOT_PATH . 'includes/functions.' . PHPEXT;
include ROOT_PATH . 'includes/unlocalised.' . PHPEXT;
include ROOT_PATH . 'includes/todofleetcontrol.' . PHPEXT;
include ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg';
include ROOT_PATH . 'includes/vars.' . PHPEXT;
include ROOT_PATH . 'includes/db.' . PHPEXT;
include ROOT_PATH . 'includes/strings.' . PHPEXT;
include ROOT_PATH . 'includes/databaseinfos.php';
include ROOT_PATH . 'includes/migrateinfo.php';
// }}}
コード例 #22
0
ファイル: class-nova-init.php プロジェクト: sayedwp/supernova
 /**
  * Build the variables.
  *
  * @return array 	('variable-name' => value)
  */
 public function get_variables()
 {
     $variables = array();
     /**
      * Loop through all fields
      */
     foreach (Nova::$fields as $field) {
         /**
          * Check if we have variables for this field
          */
         if (isset($field['variables']) && false != $field['variables'] && !empty($field['variables'])) {
             /**
              * Loop through the array of variables
              */
             foreach ($field['variables'] as $field_variable) {
                 /**
                  * Is the variable ['name'] defined?
                  * If yes, then we can proceed.
                  */
                 if (isset($field_variable['name'])) {
                     /**
                      * Sanitize the variable name
                      */
                     $variable_name = esc_attr($field_variable['name']);
                     /**
                      * Do we have a callback function defined?
                      * If not then set $variable_callback to false.
                      */
                     $variable_callback = isset($field_variable['callback']) && is_callable($field_variable['callback']) ? $field_variable['callback'] : false;
                     /**
                      * If we have a variable_callback defined then get the value of the option
                      * and run it through the callback function.
                      * If no callback is defined (false) then just get the value.
                      */
                     if ($variable_callback) {
                         $variables[$variable_name] = call_user_func($field_variable['callback'], Nova::get_option(Nova_Field_Sanitize::sanitize_settings($field)));
                     } else {
                         $variables[$variable_name] = Nova::get_option($field['settings']);
                     }
                 }
             }
         }
     }
     /**
      * Pass the variables through a filter ('nova/variable')
      * and return the array of variables
      */
     return apply_filters('nova/variable', $variables);
 }
コード例 #23
0
 /**
  * Returns the URL of this service, or optionally that of
  * an instance
  *
  * @param string $resource the resource required
  * @param array $args extra arguments to pass to the URL as query strings
  */
 public function Url($resource = self::URL_RESOURCE, $args = array())
 {
     return parent::Url($resource, $args);
 }
コード例 #24
0
ファイル: nova-settings.php プロジェクト: sayedwp/supernova
Nova::add_section('ad_spots_section', array('title' => esc_attr__('Ad Spots', 'supernova'), 'priority' => 41, 'capability' => 'edit_theme_options'));
$ad_spots = array('header' => esc_attr__('Header', 'supernova'), 'below_nav' => esc_attr__('Below Navigation', 'supernova'), 'above_posts' => esc_attr__('Above Posts', 'supernova'), 'below_posts' => esc_attr__('Below Post', 'supernova'), 'above_single_post' => esc_attr__('Above Single Post', 'supernova'), 'below_single_post' => esc_attr__('Below Single Post', 'supernova'), 'above_footer' => esc_attr__('Above Footer', 'supernova'));
foreach ($ad_spots as $key => $label) {
    Nova::add_field('supernova', array('section' => 'ad_spots_section', 'settings' => "sup_ad_spots[{$key}]", 'label' => $label, 'type' => 'code', 'choices' => array('language' => 'javascript', 'theme' => 'neat')));
}
/*
|--------------------------------------------------------------------------
| Custom CSS
|--------------------------------------------------------------------------
*/
Nova::add_section('custom_css_section', array('title' => esc_attr__('Custom CSS', 'supernova'), 'priority' => 42, 'capability' => 'edit_theme_options'));
Nova::add_field('supernova', array('type' => 'code', 'settings' => 'sup_custom_css', 'label' => esc_attr__('CSS', 'supernova'), 'section' => 'custom_css_section', 'choices' => array('language' => 'css', 'theme' => 'monokai', 'height' => 850)));
/*==============================
			BACKGROUND IMAGE
	===============================*/
//Footer Background Image
Nova::add_field('supernova', array('type' => 'upload', 'settings' => 'sup_footer_background_image', 'label' => esc_attr__('Footer Background Image', 'supernova'), 'section' => 'background_image', 'default' => SUPERNOVA_IMG_URI . '/black.png', 'transport' => 'postMessage', 'output' => array(array('element' => '.sup-site-footer', 'property' => 'background-image'))));
/*==============================
	         	 Colors
	===============================*/
//Color Schemes
Nova::add_field('', array('type' => 'palette', 'settings' => 'sup_theme_skin', 'label' => esc_attr__('Theme Skin', 'supernova'), 'description' => esc_attr__('Change color scheme.', 'supernova'), 'section' => 'colors', 'default' => 'db9f0e', 'choices' => Sup_Customizer_Front::get_palettes()));
//Heading Color
Nova::add_field('supernova', array('type' => 'color', 'settings' => 'sup_heading_color', 'label' => esc_attr__('Heading Color', 'supernova'), 'section' => 'colors', 'default' => '#525252', 'output' => array(array('element' => 'h1, h2, h3, h4, h5, h6', 'property' => 'color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => 'h1, h2, h3, h4, h5, h6', 'function' => 'css', 'property' => 'color'))));
//Footer Heading Color
Nova::add_field('supernova', array('type' => 'color', 'settings' => 'sup_footer_widget_title', 'label' => esc_attr__('Footer Heading Color', 'supernova'), 'section' => 'colors', 'default' => '#fff', 'output' => array(array('element' => '.widget-title-footer', 'property' => 'color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => '.widget-title-footer', 'function' => 'css', 'property' => 'color'))));
//Footer Color
Nova::add_field('supernova', array('type' => 'color', 'settings' => 'sup_footer_color', 'label' => esc_attr__('Footer Color', 'supernova'), 'section' => 'colors', 'default' => '#ccc', 'output' => array(array('element' => '.sup-site-footer', 'property' => 'color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => '.sup-site-footer', 'function' => 'css', 'property' => 'color'))));
//Footer Background Color
Nova::add_field('supernova', array('type' => 'color', 'settings' => 'sup_footer_background-color', 'label' => esc_attr__('Footer Background Color', 'supernova'), 'description' => __('Background color will be visible when there is no background image. You can remove background image from "Background Image" section.', 'supernova'), 'section' => 'colors', 'default' => '#000', 'output' => array(array('element' => '.sup-site-footer', 'property' => 'background-color')), 'transport' => 'postMessage', 'js_vars' => array(array('element' => '.sup-site-footer', 'function' => 'css', 'property' => 'background-color'))));