|
From: <red...@us...> - 2013-08-11 23:50:06
|
Revision: 11899
http://sourceforge.net/p/xoops/svn/11899
Author: redheadedrod
Date: 2013-08-11 23:49:58 +0000 (Sun, 11 Aug 2013)
Log Message:
-----------
Added Paths:
-----------
XoopsCore/branches/2.6.x/2.6.0_redheadedrod/
XoopsCore/branches/2.6.x/2.6.0_redheadedrod/class/
XoopsCore/branches/2.6.x/2.6.0_redheadedrod/class/database/
XoopsCore/branches/2.6.x/2.6.0_redheadedrod/class/database/mysqldatabase.php
XoopsCore/branches/2.6.x/2.6.0_redheadedrod/class/moduleadmin.php
Added: XoopsCore/branches/2.6.x/2.6.0_redheadedrod/class/database/mysqldatabase.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_redheadedrod/class/database/mysqldatabase.php (rev 0)
+++ XoopsCore/branches/2.6.x/2.6.0_redheadedrod/class/database/mysqldatabase.php 2013-08-11 23:49:58 UTC (rev 11899)
@@ -0,0 +1,408 @@
+<?php
+/*
+ You may not change or alter any portion of this comment or credits
+ of supporting developers from this source code or any supporting source code
+ which is considered copyrighted (c) material of the original comment or credit authors.
+
+ 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.
+*/
+
+/**
+ * MySQL access
+ *
+ * @copyright The XOOPS project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
+ * @package class
+ * @subpackage database
+ * @since 1.0.0
+ * @author Kazumi Ono <on...@xo...>
+ * @version $Id: mysqldatabase.php 10328 2012-12-07 00:56:07Z trabis $
+ */
+
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+
+/**
+ * connection to a mysql database
+ *
+ * @abstract
+ * @author Kazumi Ono <on...@xo...>
+ * @copyright copyright (c) 2000-2003 XOOPS.org
+ * @package class
+ * @subpackage database
+ */
+class XoopsMySQLDatabase extends XoopsDatabase
+{
+
+ /**
+ * connect to the database
+ *
+ * @param bool $selectdb select the database now?
+ * @return bool successful?
+ */
+ public function connect($selectdb = true)
+ {
+ static $db_charset_set;
+
+ if (!extension_loaded('mysql')) {
+ trigger_error('notrace:mysql extension not loaded', E_USER_ERROR);
+ return false;
+ }
+
+ $this->allowWebChanges = ($_SERVER['REQUEST_METHOD'] != 'GET');
+
+ if (XOOPS_DB_PCONNECT == 1) {
+ $this->conn = @mysql_pconnect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS);
+ } else {
+ $this->conn = @mysql_connect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS);
+ }
+
+ if (!$this->conn) {
+ $xoopsPreload = XoopsPreload::getInstance();
+ $xoopsPreload->triggerEvent('core.database.noconn', array($this));
+ return false;
+ }
+ if ($selectdb != false) {
+ if (!mysql_select_db(XOOPS_DB_NAME)) {
+ $xoopsPreload = XoopsPreload::getInstance();
+ $xoopsPreload->triggerEvent('core.database.nodb');
+ return false;
+ }
+ }
+ if (!isset($db_charset_set) && defined('XOOPS_DB_CHARSET') && XOOPS_DB_CHARSET) {
+ $this->queryF("SET NAMES '" . XOOPS_DB_CHARSET . "'");
+ }
+ $db_charset_set = 1;
+ $this->queryF("SET SQL_BIG_SELECTS = 1");
+ return true;
+ }
+
+ /**
+ * Return information about the database server in use
+ *
+ * This is a new function added for 2.5.7 and later to allow support for other databases.
+ *
+ * @return will return version of server in use
+ */
+ function getServerVersion()
+ {
+ return mysql_get_server_info();
+ }
+
+ /**
+ * generate an ID for a new row
+ *
+ * This is for compatibility only. Will always return 0, because MySQL supports
+ * autoincrement for primary keys.
+ *
+ * @param string $sequence name of the sequence from which to get the next ID
+ * @return int always 0, because mysql has support for autoincrement
+ */
+ public function genId($sequence)
+ {
+ return 0; // will use auto_increment
+ }
+
+ /**
+ * Get a result row as an enumerated array
+ *
+ * @param resource $result
+ * @return array
+ */
+ public function fetchRow($result)
+ {
+ return @mysql_fetch_row($result);
+ }
+
+ /**
+ * Fetch a result row as an associative array
+ *
+ * @param resource $result
+ * @return array
+ */
+ public function fetchArray($result)
+ {
+ return @mysql_fetch_assoc($result);
+ }
+
+ /**
+ * Fetch a result row as an associative array
+ *
+ * @param resource $result
+ * @return array
+ */
+ public function fetchBoth($result)
+ {
+ return @mysql_fetch_array($result, MYSQL_BOTH);
+ }
+
+ /**
+ * XoopsMySQLDatabase::fetchObjected()
+ *
+ * @param resource $result
+ * @return object|stdClass
+ */
+ public function fetchObject($result)
+ {
+ return @mysql_fetch_object($result);
+ }
+
+ /**
+ * Get the ID generated from the previous INSERT operation
+ *
+ * @return int
+ */
+ public function getInsertId()
+ {
+ return mysql_insert_id($this->conn);
+ }
+
+ /**
+ * Get number of rows in result
+ *
+ * @param resource $result
+ * @return int
+ */
+ public function getRowsNum($result)
+ {
+ return @mysql_num_rows($result);
+ }
+
+ /**
+ * Get number of affected rows
+ *
+ * @return int
+ */
+ public function getAffectedRows()
+ {
+ return mysql_affected_rows($this->conn);
+ }
+
+ /**
+ * Close MySQL connection
+ *
+ * @return void
+ */
+ public function close()
+ {
+ mysql_close($this->conn);
+ }
+
+ /**
+ * will free all memory associated with the result identifier result.
+ *
+ * @param resource $result query result
+ * @return bool TRUE on success or FALSE on failure.
+ */
+ public function freeRecordSet($result)
+ {
+ return mysql_free_result($result);
+ }
+
+ /**
+ * Returns the text of the error message from previous MySQL operation
+ *
+ * @return bool Returns the error text from the last MySQL function, or '' (the empty string) if no error occurred.
+ */
+ public function error()
+ {
+ return @mysql_error();
+ }
+
+ /**
+ * Returns the numerical value of the error message from previous MySQL operation
+ *
+ * @return int Returns the error number from the last MySQL function, or 0 (zero) if no error occurred.
+ */
+ public function errno()
+ {
+ return @mysql_errno();
+ }
+
+ /**
+ * Returns escaped string text with single quotes around it to be safely stored in database
+ *
+ * @param string $str unescaped string text
+ * @return string escaped string text with single quotes around
+ */
+ public function quoteString($str)
+ {
+ return $this->quote($str);
+ }
+
+ /**
+ * Quotes a string for use in a query.
+ *
+ * @param $string
+ * @return string
+ */
+ public function quote($string)
+ {
+ return "'" . str_replace("\\\"", '"', str_replace("\\"", '"', mysql_real_escape_string($string, $this->conn))) . "'";
+ }
+
+ /**
+ * perform a query on the database
+ *
+ * @param string $sql a valid MySQL query
+ * @param int $limit number of records to return
+ * @param int $start offset of first record to return
+ * @return bool|resource query result or FALSE if successful
+ * or TRUE if successful and no result
+ */
+ public function queryF($sql, $limit = 0, $start = 0)
+ {
+ if (!empty($limit)) {
+ if (empty($start)) {
+ $start = 0;
+ }
+ $sql = $sql . ' LIMIT ' . (int) $start . ', ' . (int) $limit;
+ }
+ $xoopsPreload = XoopsPreload::getInstance();
+ $xoopsPreload->triggerEvent('core.database.query.start');
+ $result = mysql_query($sql, $this->conn);
+ $xoopsPreload->triggerEvent('core.database.query.end');
+
+ if ($result) {
+ $xoopsPreload->triggerEvent('core.database.query.success', (array($sql)));
+ return $result;
+ } else {
+ $xoopsPreload->triggerEvent('core.database.query.failure', (array($sql, $this)));
+ return false;
+ }
+ }
+
+ /**
+ * perform a query
+ *
+ * This method is empty and does nothing! It should therefore only be
+ * used if nothing is exactly what you want done! ;-)
+ *
+ * @param string $sql a valid MySQL query
+ * @param int $limit number of records to return
+ * @param int $start offset of first record to return
+ * @abstract
+ */
+ public function query($sql, $limit = 0, $start = 0)
+ {
+ }
+
+ /**
+ * perform queries from SQL dump file in a batch
+ *
+ * @param string $file file path to an SQL dump file
+ * @return bool FALSE if failed reading SQL file or TRUE if the file has been read and queries executed
+ */
+ public function queryFromFile($file)
+ {
+ if (false !== ($fp = fopen($file, 'r'))) {
+ $sql_queries = trim(fread($fp, filesize($file)));
+ SqlUtility::splitMySqlFile($pieces, $sql_queries);
+ foreach ($pieces as $query) {
+ // [0] contains the prefixed query
+ // [4] contains unprefixed table name
+ $prefixed_query = SqlUtility::prefixQuery(trim($query), $this->prefix());
+ if ($prefixed_query != false) {
+ $this->query($prefixed_query[0]);
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Get field name
+ *
+ * @param resource $result query result
+ * @param int $offset numerical field index
+ * @return string
+ */
+ public function getFieldName($result, $offset)
+ {
+ return mysql_field_name($result, $offset);
+ }
+
+ /**
+ * Get field type
+ *
+ * @param resource $result query result
+ * @param int $offset numerical field index
+ * @return string
+ */
+ public function getFieldType($result, $offset)
+ {
+ return mysql_field_type($result, $offset);
+ }
+
+ /**
+ * Get number of fields in result
+ *
+ * @param resource $result query result
+ * @return int
+ */
+ public function getFieldsNum($result)
+ {
+ return mysql_num_fields($result);
+ }
+}
+
+/**
+ * Safe Connection to a MySQL database.
+ *
+ * @author Kazumi Ono <on...@xo...>
+ * @copyright copyright (c) 2000-2003 XOOPS.org
+ * @package kernel
+ * @subpackage database
+ */
+class XoopsMySQLDatabaseSafe extends XoopsMySQLDatabase
+{
+ /**
+ * perform a query on the database
+ *
+ * @param string $sql a valid MySQL query
+ * @param int $limit number of records to return
+ * @param int $start offset of first record to return
+ * @return resource query result or FALSE if successful
+ * or TRUE if successful and no result
+ */
+ public function query($sql, $limit = 0, $start = 0)
+ {
+ return $this->queryF($sql, $limit, $start);
+ }
+}
+
+/**
+ * Read-Only connection to a MySQL database.
+ *
+ * This class allows only SELECT queries to be performed through its
+ * {@link query()} method for security reasons.
+ *
+ * @author Kazumi Ono <on...@xo...>
+ * @copyright copyright (c) 2000-2003 XOOPS.org
+ * @package kernel
+ * @subpackage database
+ */
+class XoopsMySQLDatabaseProxy extends XoopsMySQLDatabase
+{
+ /**
+ * perform a query on the database
+ *
+ * this method allows only SELECT queries for safety.
+ *
+ * @param string $sql a valid MySQL query
+ * @param int $limit number of records to return
+ * @param int $start offset of first record to return
+ * @return resource query result or FALSE if unsuccessful
+ */
+ public function query($sql, $limit = 0, $start = 0)
+ {
+ $sql = ltrim($sql);
+ if (!$this->allowWebChanges && strtolower(substr($sql, 0, 6)) != 'select') {
+ trigger_error('Database updates are not allowed during processing of a GET request', E_USER_WARNING);
+ return false;
+ }
+ return $this->queryF($sql, $limit, $start);
+ }
+}
\ No newline at end of file
Added: XoopsCore/branches/2.6.x/2.6.0_redheadedrod/class/moduleadmin.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_redheadedrod/class/moduleadmin.php (rev 0)
+++ XoopsCore/branches/2.6.x/2.6.0_redheadedrod/class/moduleadmin.php 2013-08-11 23:49:58 UTC (rev 11899)
@@ -0,0 +1,537 @@
+<?php
+/*
+ You may not change or alter any portion of this comment or credits
+ of supporting developers from this source code or any supporting source code
+ which is considered copyrighted (c) material of the original comment or credit authors.
+
+ 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.
+*/
+
+/**
+ * Xoops Moduleadmin Classes
+ *
+ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
+ * @package class
+ * @since 2.6.0
+ * @author Mage Grégory (AKA Mage)
+ * @version $Id: moduleadmin.php 10677 2013-01-06 01:12:16Z trabis $
+ */
+
+class XoopsModuleAdmin
+{
+ /**
+ * Set module directory
+ *
+ * @var string
+ */
+ public $_tplModule = 'system';
+
+ /**
+ * Template call for each render parts
+ *
+ * @var array
+ */
+ public $_tplFile = array(
+ 'index' => 'admin_index.html', 'about' => 'admin_about.html', 'infobox' => 'admin_infobox.html',
+ 'bread' => 'admin_breadcrumb.html', 'button' => 'admin_buttons.html', 'tips' => 'admin_tips.html',
+ 'nav' => 'admin_navigation.html'
+ );
+
+ /**
+ * Tips to display in admin page
+ *
+ * @var string
+ */
+ private $_tips = '';
+
+ /**
+ * List of button
+ *
+ * @var array
+ */
+ private $_itemButton = array();
+
+ /**
+ * List of Info Box
+ *
+ * @var array
+ */
+ private $_itemInfoBox = array();
+
+ /**
+ * List of line of an Info Box
+ *
+ * @var array
+ */
+ private $_itemConfigBoxLine = array();
+
+ /**
+ * Breadcrumb data
+ *
+ * @var array
+ */
+ private $_bread = array();
+
+ /**
+ * Current module object
+ *
+ * @var XoopsModule $_obj
+ */
+ private $_obj = null;
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ $xoops = Xoops::getInstance();
+ $this->_obj = $xoops->module;
+ $xoops->theme()->addStylesheet('media/xoops/css/moduladmin.css');
+ }
+
+ /**
+ * Add breadcrumb menu
+ *
+ * @param string $title
+ * @param string $link
+ * @param bool $home
+ */
+ public function addBreadcrumbLink($title = '', $link = '', $home = false)
+ {
+ if ($title != '') {
+ $this->_bread[] = array(
+ 'link' => $link, 'title' => $title, 'home' => $home
+ );
+ }
+ }
+
+ /**
+ * Add config line
+ *
+ * @param string $value
+ * @param string $type
+ *
+ * @return bool
+ */
+ public function addConfigBoxLine($value = '', $type = 'default')
+ {
+ switch ($type) {
+ default:
+ case "default":
+ $this->_itemConfigBoxLine[] = array('type' => $type, 'text' => $value);
+ break;
+
+ case "folder":
+ if (!is_dir($value)) {
+ $this->_itemConfigBoxLine[] = array(
+ 'type' => 'error', 'text' => sprintf(_AM_MODULEADMIN_CONFIG_FOLDERKO, $value)
+ );
+ } else {
+ $this->_itemConfigBoxLine[] = array(
+ 'type' => 'accept', 'text' => sprintf(_AM_MODULEADMIN_CONFIG_FOLDEROK, $value)
+ );
+ }
+ break;
+
+ case "chmod":
+ if (is_dir($value[0])) {
+ if (substr(decoct(fileperms($value[0])), 2) != $value[1]) {
+ $this->_itemConfigBoxLine[] = array(
+ 'type' => 'error',
+ 'text' => sprintf(_AM_MODULEADMIN_CONFIG_CHMOD, $value[0], $value[1], substr(decoct(fileperms($value[0])), 2))
+ );
+ } else {
+ $this->_itemConfigBoxLine[] = array(
+ 'type' => 'accept',
+ 'text' => sprintf(_AM_MODULEADMIN_CONFIG_CHMOD, $value[0], $value[1], substr(decoct(fileperms($value[0])), 2))
+ );
+ }
+ }
+ break;
+
+ case "extension":
+ $xoops = Xoops::getInstance();
+ if (is_array($value)) {
+ $text = $value[0];
+ $type = $value[1];
+ } else {
+ $text = $value;
+ $type = 'error';
+ }
+ if ($xoops->isActiveModule($text) == false) {
+ $this->_itemConfigBoxLine[] = array(
+ 'type' => $type, 'text' => sprintf(_AM_MODULEADMIN_CONFIG_EXTENSIONKO, $text)
+ );
+ } else {
+ $this->_itemConfigBoxLine[] = array(
+ 'type' => 'accept', 'text' => sprintf(_AM_MODULEADMIN_CONFIG_EXTENSIONOK, $text)
+ );
+ }
+ break;
+
+ case "module":
+ $xoops = Xoops::getInstance();
+ if (is_array($value)) {
+ $text = $value[0];
+ $type = $value[1];
+ } else {
+ $text = $value;
+ $type = 'error';
+ }
+ if ($xoops->isActiveModule($text) == false) {
+ $this->_itemConfigBoxLine[] = array(
+ 'type' => $type, 'text' => sprintf(_AM_MODULEADMIN_CONFIG_MODULEKO, $text)
+ );
+ } else {
+ $this->_itemConfigBoxLine[] = array(
+ 'type' => 'accept', 'text' => sprintf(_AM_MODULEADMIN_CONFIG_MODULEOK, $text)
+ );
+ }
+ break;
+ }
+ return true;
+ }
+
+ /**
+ * Add Info box
+ *
+ * @param $title
+ * @param string $type
+ * @param string $extra
+ *
+ * @return bool
+ */
+ public function addInfoBox($title, $type = 'default', $extra = '')
+ {
+ $ret['title'] = $title;
+ $ret['type'] = $type;
+ $ret['extra'] = $extra;
+ $this->_itemInfoBox[] = $ret;
+ return true;
+ }
+
+ /**
+ * Add line to the info box
+ *
+ * @param string $text
+ * @param string $type
+ * @param string $color
+ *
+ * @return bool
+ */
+ public function addInfoBoxLine($text = '', $type = 'default', $color = 'inherit')
+ {
+ $ret = array();
+ $ret['text'] = $text;
+ $ret['color'] = $color;
+
+ foreach (array_keys($this->_itemInfoBox) as $i) {
+ if ($this->_itemInfoBox[$i]['type'] == $type) {
+ $this->_itemInfoBox[$i]['line'][] = $ret;
+ unset($ret);
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Add Item button
+ *
+ * @param $title
+ * @param $link
+ * @param string $icon
+ * @param string $extra
+ *
+ * @return bool
+ */
+ public function addItemButton($title, $link, $icon = 'add', $extra = '')
+ {
+ $ret['title'] = $title;
+ $ret['link'] = $link;
+ $ret['icon'] = $icon;
+ $ret['extra'] = $extra;
+ $this->_itemButton[] = $ret;
+ return true;
+ }
+
+ /**
+ * Add a tips
+ *
+ * @param string $text
+ */
+ public function addTips($text = '')
+ {
+ $this->_tips = $text;
+ }
+
+ /**
+ * Construct template path
+ *
+ * @param string $type
+ *
+ * @return string
+ */
+ private function getTplPath($type = '')
+ {
+ return 'admin:' . $this->_tplModule . '|' . $this->_tplFile[$type];
+ }
+
+ public function renderBreadcrumb()
+ {
+ $xoops = Xoops::getInstance();
+ $xoops->tpl()->assign('xo_admin_breadcrumb', $this->_bread);
+ return $xoops->tpl()->fetch($this->getTplPath('bread'));
+ }
+
+ public function displayBreadcrumb()
+ {
+ echo $this->renderBreadcrumb();
+ }
+
+ /**
+ * Render all items buttons
+ *
+ * @param string $position
+ * @param string $delimiter
+ *
+ * @return string
+ */
+ public function renderButton($position = "floatright", $delimiter = " ")
+ {
+ $xoops = Xoops::getInstance();
+
+ $xoops->tpl()->assign('xo_admin_buttons_position', $position);
+ $xoops->tpl()->assign('xo_admin_buttons_delim', $delimiter);
+ $xoops->tpl()->assign('xo_admin_buttons', $this->_itemButton);
+ return $xoops->tpl()->fetch($this->getTplPath('button'));
+ }
+
+ /**
+ * @param string $position
+ * @param string $delimiter
+ */
+ public function displayButton($position = "floatright", $delimiter = " ")
+ {
+ echo $this->renderButton($position, $delimiter);
+ }
+
+ /**
+ * Render InfoBox
+ */
+ public function renderInfoBox()
+ {
+ $xoops = Xoops::getInstance();
+ $xoops->tpl()->assign('xo_admin_box', $this->_itemInfoBox);
+ return $xoops->tpl()->fetch($this->getTplPath('infobox'));
+ }
+
+ public function displayInfoBox()
+ {
+ echo $this->renderInfoBox();
+ }
+
+ /**
+ * Render index page for admin
+ */
+ public function renderIndex()
+ {
+ $xoops = Xoops::getInstance();
+ $this->_obj->loadAdminMenu();
+ foreach (array_keys($this->_obj->adminmenu) as $i) {
+ if (XoopsLoad::fileExists($xoops->path("/media/xoops/images/icons/32/" . $this->_obj->adminmenu[$i]['icon']))) {
+ $this->_obj->adminmenu[$i]['icon'] = $xoops->url("/media/xoops/images/icons/32/" . $this->_obj->adminmenu[$i]['icon']);
+ } else {
+ $this->_obj->adminmenu[$i]['icon'] = $xoops->url("/modules/" . $xoops->module->dirname() . "/icons/32/" . $this->_obj->adminmenu[$i]['icon']);
+ }
+ $xoops->tpl()->append('xo_admin_index_menu', $this->_obj->adminmenu[$i]);
+ }
+ if ($this->_obj->getInfo('help')) {
+ $help = array();
+ $help['link'] = '../system/help.php?mid=' . $this->_obj->getVar('mid', 's') . "&" . $this->_obj->getInfo('help');
+ $help['icon'] = $xoops->url("/media/xoops/images/icons/32/help.png");
+ $help['title'] = _AM_SYSTEM_HELP;
+ $xoops->tpl()->append('xo_admin_index_menu', $help);
+ }
+ $xoops->tpl()->assign('xo_admin_box', $this->_itemInfoBox);
+
+ // If you use a config label
+ if ($this->_obj->getInfo('min_php') || $this->_obj->getInfo('min_xoops') || !empty($this->_itemConfigBoxLine)) {
+ // PHP version
+ if ($this->_obj->getInfo('min_php')) {
+ if (phpversion() < $this->_obj->getInfo('min_php')) {
+ $this->addConfigBoxLine(sprintf(_AM_MODULEADMIN_CONFIG_PHP, $this->_obj->getInfo('min_php'), phpversion()), 'error');
+ } else {
+ $this->addConfigBoxLine(sprintf(_AM_MODULEADMIN_CONFIG_PHP, $this->_obj->getInfo('min_php'), phpversion()), 'accept');
+ }
+ }
+ // Database version
+ $dbarray = $this->_obj->getInfo('min_db');
+ if ($dbarray[XOOPS_DB_TYPE]) {
+ global $xoopsDB;
+ $dbCurrentVersion= $xoopsDB->getServerVersion();
+ $currentVerParts = explode('.', (string)$dbCurrentVersion);
+ $iCurrentVerParts = array_map('intval', $currentVerParts);
+ $dbRequiredVersion = $dbarray[XOOPS_DB_TYPE];
+ $reqVerParts = explode('.', (string)$dbRequiredVersion);
+ $iReqVerParts = array_map('intval', $reqVerParts);
+ $icount = $j = count($iReqVerParts);
+ $reqVer = $curVer = 0;
+ for ($i = 0; $i < $icount; $i++) {
+ $j--;
+ $reqVer += $iReqVerParts[$i] * pow(10, $j);
+ if (isset($iCurrentVerParts[$i])) {
+ $curVer += $iCurrentVerParts[$i] * pow(10, $j);
+ } else {
+ $curVer = $curVer * pow(10, $j);
+ }
+ }
+ if ($reqVer > $curVer) {
+ $this->addConfigBoxLine(sprintf(strtoupper(XOOPS_DB_TYPE) . ' ' . _AM_MODULEADMIN_CONFIG_DB, $dbRequiredVersion, $dbCurrentVersion), 'error');
+ } else {
+ $this->addConfigBoxLine(sprintf(strtoupper(XOOPS_DB_TYPE) . ' ' . _AM_MODULEADMIN_CONFIG_DB, $dbRequiredVersion, $dbCurrentVersion), 'accept');
+ }
+ }
+
+ // xoops version
+ if ($this->_obj->getInfo('min_xoops')) {
+ if (substr(XOOPS_VERSION, 6, strlen(XOOPS_VERSION) - 6) < $this->_obj->getInfo('min_xoops')) {
+ $this->addConfigBoxLine(sprintf(_AM_MODULEADMIN_CONFIG_XOOPS, $this->_obj->getInfo('min_xoops'), substr(XOOPS_VERSION, 6, strlen(XOOPS_VERSION) - 6)), 'error');
+ } else {
+ $this->addConfigBoxLine(sprintf(_AM_MODULEADMIN_CONFIG_XOOPS, $this->_obj->getInfo('min_xoops'), substr(XOOPS_VERSION, 6, strlen(XOOPS_VERSION) - 6)), 'accept');
+ }
+ }
+ $xoops->tpl()->assign('xo_admin_index_config', $this->_itemConfigBoxLine);
+ }
+ return $xoops->tpl()->fetch($this->getTplPath('index'));
+ }
+
+ public function displayIndex()
+ {
+ echo $this->renderIndex();
+ }
+
+ /**
+ * Render navigation to admin page
+ *
+ * @param string $menu
+ *
+ * @return array
+ */
+ public function renderNavigation($menu = '')
+ {
+ $xoops = Xoops::getInstance();
+ $ret = array();
+
+ $this->_obj->loadAdminMenu();
+ foreach (array_keys($this->_obj->adminmenu) as $i) {
+ if ($this->_obj->adminmenu[$i]['link'] == "admin/" . $menu) {
+ if (XoopsLoad::fileExists($xoops->path("/media/xoops/images/icons/32/" . $this->_obj->adminmenu[$i]['icon']))) {
+ $this->_obj->adminmenu[$i]['icon'] = $xoops->url("/media/xoops/images/icons/32/" . $this->_obj->adminmenu[$i]['icon']);
+ } else {
+ $this->_obj->adminmenu[$i]['icon'] = $xoops->url("/modules/" . $xoops->module->dirname() . "/icons/32/" . $this->_obj->adminmenu[$i]['icon']);
+ }
+ $xoops->tpl()->assign('xo_sys_navigation', $this->_obj->adminmenu[$i]);
+ $ret[] = $xoops->tpl()->fetch($this->getTplPath('nav'));
+ }
+ }
+ return $ret;
+ }
+
+ /**
+ * @param string $menu
+ */
+ public function displayNavigation($menu = '')
+ {
+ $items = $this->renderNavigation($menu);
+ foreach ($items as $item) {
+ echo $item;
+ }
+ }
+
+ /**
+ * Render tips to admin page
+ */
+ public function renderTips()
+ {
+ $xoops = Xoops::getInstance();
+ $xoops->tpl()->assign('xo_admin_tips', $this->_tips);
+ return $xoops->tpl()->fetch($this->getTplPath('tips'));
+ }
+
+ public function displayTips()
+ {
+ echo $this->renderTips();
+ }
+
+ /**
+ * Render about page
+ *
+ * @param bool $logo_xoops
+ *
+ * @return bool|mixed|string
+ */
+ public function renderAbout($logo_xoops = true)
+ {
+ $xoops = Xoops::getInstance();
+
+ $date = explode('/', $this->_obj->getInfo('release_date'));
+ $author = explode(',', $this->_obj->getInfo('author'));
+ $nickname = explode(',', $this->_obj->getInfo('nickname'));
+ $release_date = XoopsLocal::formatTimestamp(mktime(0, 0, 0, $date[1], $date[2], $date[0]), 's');
+
+ $author_list = '';
+ foreach (array_keys($author) as $i) {
+ $author_list .= $author[$i];
+ if (isset($nickname[$i]) && $nickname[$i] != '') {
+ $author_list .= " (" . $nickname[$i] . "), ";
+ } else {
+ $author_list .= ", ";
+ }
+ }
+ $changelog = '';
+ $language = $xoops->getConfig('language');
+ if (!is_file(XOOPS_ROOT_PATH . "/modules/" . $this->_obj->getVar("dirname") . "/language/" . $language . "/changelog.txt")) {
+ $language = 'english';
+ }
+ $language = empty($language) ? $xoops->getConfig('language') : $language;
+ $file = XOOPS_ROOT_PATH . "/modules/" . $this->_obj->getVar("dirname") . "/language/" . $language . "/changelog.txt";
+ if (is_readable($file)) {
+ $changelog = utf8_encode(implode("<br />", file($file))) . "\n";
+ } else {
+ $file = XOOPS_ROOT_PATH . "/modules/" . $this->_obj->getVar("dirname") . "/docs/changelog.txt";
+ if (is_readable($file)) {
+ $changelog = utf8_encode(implode("<br />", file($file))) . "\n";
+ }
+ }
+ $author_list = substr($author_list, 0, -2);
+
+ $this->_obj->setInfo('release_date', $release_date);
+ $this->_obj->setInfo('author_list', $author_list);
+ if (is_array($this->_obj->getInfo('paypal'))) {
+ $this->_obj->setInfo('paypal', $this->_obj->getInfo('paypal'));
+ }
+ $this->_obj->setInfo('changelog', $changelog);
+ $xoops->tpl()->assign('module', $this->_obj);
+
+ $this->addInfoBox(_AM_MODULEADMIN_ABOUT_MODULEINFO, 'info', 'id="xo-about"');
+ $this->addInfoBoxLine(_AM_MODULEADMIN_ABOUT_DESCRIPTION . ' ' . $this->_obj->getInfo("description"), 'info');
+ $this->addInfoBoxLine(_AM_MODULEADMIN_ABOUT_UPDATEDATE . ' <span class="bold">' . XoopsLocal::formatTimestamp($this->_obj->getVar("last_update"), "m") . '</span>', 'info');
+ $this->addInfoBoxLine(_AM_MODULEADMIN_ABOUT_WEBSITE . ' <a class="xo-tooltip" href="http://' . $this->_obj->getInfo("module_website_url") . '" rel="external" title="' . $this->_obj->getInfo("module_website_name") . ' - ' . $this->_obj->getInfo("module_website_url") . '">
+ ' . $this->_obj->getInfo("module_website_name") . '</a>', 'info');
+
+ $xoops->tpl()->assign('xoops_logo', $logo_xoops);
+ $xoops->tpl()->assign('xo_admin_box', $this->_itemInfoBox);
+ return $xoops->tpl()->fetch($this->getTplPath('about'));
+ }
+
+ /**
+ * @param bool $logo_xoops
+ */
+ public function displayAbout($logo_xoops = true)
+ {
+ echo $this->renderAbout($logo_xoops);
+ }
+}
\ No newline at end of file
|