Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any documentation?
#1
Especially for plugins? A list of the hooks available would be cool.
Reply
#2
I've found some
Hooks:

nav-tab - top of admin panel will be beside [backup]
Quote:
  • Data 1 - The url of the page.
    Example: plugins.php?plugin=main
  • Data 2 - The name of the page, could be a language variable which you should encase with $il8n[]; or text. Example: $il8n['PLUGIN_NAV']
Code:
add_action('nav-tab', 'createNavTab', array('data-1', data-2));

plugin-tab
- inside of admin panel plugin page below other plugin tabs
Code:
add_action('plugin-sidebar','createSideMenu', array('folderthatyourpluginpageisin','pagename','Title of page'));
http://nijikokun.com
random stuff. idk.
Reply
#3
Documentation is coming for the plugins soon... We are still trying to finalize where the hooks should be: http://get-simple.info/forum/viewtopic.php?id=325

Almost everything else is here
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#4
What about the include paths? I'm having trouble creating a plugin b/c it's in the plugins/myplugin folder, and I can't include the functions.php file because it's 3 directories up. Since there is no bootstrap file or constants I'm finding it difficult to just create a file in my plugin folder, and including all the necessary inc/core files.
Reply
#5
We know about this. It is a failure on my part when I originally created GS. Without a complete rewrite of the code, I do not know how I am going to do this.

NY suggested using common.php for this, and it might work, but I am not familiar with finding document root enough to write something that is cross-platform to include there. Feel free to contribute code that would help us all...

BTW: Any variable in common.php will be available to any plugin page/page within the admin panel.
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#6
This right here should always return the full path to the admin folder, so long as the admin folder isn't renamed.

Code:
function get_admin_path()
    {
        $path = dirname(__FILE__) . '/';
        $segments = explode('/', $path);

        foreach($segments as $k => $segment)
        {
            if($segment === 'admin')
            {
                $new_segments = array_slice($segments, 0, $k+1);
                break;
            }
        }

        return implode('/', $new_segments) . '/';
    }
Reply
#7
litzinger - Thanks! Doesn't look so hard there... I think I am going to add this into the common.php file as a defined variable. I just tested and it shows the same path no matter where I am in the admin panel.

Any idea how to get the root of the whole installation? (where index.php and .htaccess is located)
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#8
Ok, I have a feeling this could work, or I could be onto something. It would involve setting the include path if someone defines either PATH_ADMIN or PATH_ROOT before trying to load those files, then from there on out those files will set the include path if either one of those constants are defined.

The following is in admin/plugins/channels/index.php

Code:
/****************************************************
*
* @File:     channels.php
* @Package:    GetSimple
* @Action:    Edit or create new pages for the website.    
*
*****************************************************/
    require_once('config.php');

    require_once(PATH_ADMIN.'inc/functions.php');
    require_once(PATH_ADMIN.'inc/plugin_functions.php');
    
    $userid = login_cookie_check();
    $id         = @$_GET['id'];
    $ptype     = @$_GET['type'];
    $path     = tsl(PATH_ROOT.'data/other/channels/');
    $counter = '0';
    $table = '';

admin/plugins/channels/config.php

Code:
<?php

function get_path($up = 1)
{
    $path = dirname(__FILE__) . '/';
    $segments = explode('/', $path);

    foreach($segments as $k => $segment)
    {
        if($segment === 'admin')
        {
            $new_segments = array_slice($segments, 0, $k+$up);
            break;
        }
    }

    return implode('/', $new_segments) . '/';
}

define('PATH_ADMIN', get_path());
define('PATH_ROOT', get_path(0));

admin/inc/functions.php

Code:
<?php
/****************************************************
*
* @File:     functions.php
* @Package:    GetSimple
* @Action:    Initialize needed functions for cp.    
*
*****************************************************/
    
    if(defined('PATH_ADMIN')){
        set_include_path(
         '.' . PATH_SEPARATOR . PATH_ADMIN
            . PATH_SEPARATOR . get_include_path()
        );
    }
    
    if(defined('PATH_ROOT')){
        set_include_path(
         '.' . PATH_SEPARATOR . PATH_ROOT
            . PATH_SEPARATOR . get_include_path()
        );
    }
Reply
#9
I think I'm going to rewrite a lot of get simple to revolve around a common file, this would solve about 80% of problems.

I see where you main problem is, you already have basically a common file just you named it terribly.

Your file system:
Code:
- functions.php [ not really functions but inclusions ]
  - common.php [ where inclusions and setting configurations are to be made ]


This is where its wrong.

It should be like this:

Code:
- variables for common
- common
- configuration
  - classes / functions
---------------------------
  - coding

So that way:

Code:
<?php
/****************************************************
*
* @File:     index.php
* @Package:    GetSimple
* @Action:    Login screen for the control panel.    
*
*****************************************************/

// What should we load?
$load['login'] = true;
$load['plugin'] = true;

require_once('inc/common.php');
?>

Inside of common.php
Code:
/****************************************************
*
* @File:     common.php
* @Package:    GetSimple
* @Action:    base of site
*
*****************************************************/
// Defined in get simple?
define('IN_GS', true);

// Base files needed on every page
require_once('inc/cookie_functions.php');
require_once('inc/template_functions.php');

// Load configuration


// Check installation

// Timezone stuff

// Language settings

// Include extra files
if($load['login']){}
if($load['plugin']){}

No need for multiple files, multiple code repetitions, ect. It `simplifies` things.
http://nijikokun.com
random stuff. idk.
Reply
#10
Here is what my functions.php file looks like now. Right now I'm getting a "Unable to open plugins/" error, but it's further along than before.

I like Nijikokun's approach, but that means you're going to have to use globals because there is no bootstrap. Defined constants are only available in files that include the creation of the defined variables (I think). So if admin/index.php loads common.php, then you could use the get_path method below, or something similar then create a single global var for people to use in their plugins to load files.... e.g.

Code:
global $PATH_ROOT;
require_once($PATH_ROOT . 'admin/inc/functions.php');

That may be a way around the set_include_path method I tried below, but I don't know what other implications that may have because I'm very unfamiliar with the code base.

I noticed the site doesn't really use constants, so I changed it to capitalized variables.

Code:
<?php

function get_path($up = 0)
{
    $path = dirname(__FILE__) . '/';
    $segments = explode('/', $path);

    foreach($segments as $k => $segment)
    {
        if($segment === 'admin')
        {
            $new_segments = array_slice($segments, 0, $k+$up);
            break;
        }
    }

    return implode('/', $new_segments) . '/';
}

$PATH_ADMIN = get_path(1);
$PATH_ROOT = get_path();

Code:
<?php
/****************************************************
*
* @File:     functions.php
* @Package:    GetSimple
* @Action:    Initialize needed functions for cp.    
*
*****************************************************/

    $INC_PATH_ROOT = '../';
    
    if($PATH_ADMIN){
        set_include_path(
         '.' . PATH_SEPARATOR . $PATH_ADMIN
            . PATH_SEPARATOR . get_include_path()
        );
    }
    
    if($PATH_ROOT){
        set_include_path(
         '.' . PATH_SEPARATOR . $PATH_ROOT
            . PATH_SEPARATOR . get_include_path()
        );
        
        $INC_PATH_ROOT = $PATH_ROOT;
    }

    //disable or enable error reporting
    if (file_exists($INC_PATH_ROOT.'data/other/debug.xml')) {
        error_reporting(E_ALL | E_STRICT);
        ini_set('display_errors', 1);
    } else {
        error_reporting(0);
        @ini_set('display_errors', 0);
    }
    ini_set('log_errors', 1);
    ini_set('error_log', $INC_PATH_ROOT.'data/other/logs/errorlog.txt');
    
    
    //include other function files
    require_once('inc/cookie_functions.php');
    require_once('inc/template_functions.php');
    require_once('inc/common.php');
    
    //get website data
    if (file_exists($INC_PATH_ROOT.'data/other/website.xml')) {
        $thisfilew = $INC_PATH_ROOT.'data/other/website.xml';
        $dataw = getXML($thisfilew);
        $SITENAME = stripslashes($dataw->SITENAME);
        $SITEURL = $dataw->SITEURL;
        $TEMPLATE = $dataw->TEMPLATE;
        $TIMEZONE = $dataw->TIMEZONE;
        $LANG = $dataw->LANG;
    } else {
        $TIMEZONE = 'America/New_York';
        $LANG = 'en_US';
    }
    if (file_exists($INC_PATH_ROOT.'data/other/cp_settings.xml')) {
        $thisfilec = $INC_PATH_ROOT.'data/other/cp_settings.xml';
        $datac = getXML($thisfilec);
        $HTMLEDITOR = $datac->HTMLEDITOR;
        $PRETTYURLS = $datac->PRETTYURLS;
        $FOUR04MONITOR = $datac->FOUR04MONITOR;
    }
    
    if (file_exists($INC_PATH_ROOT.'data/other/user.xml')) {
        $datau = getXML($INC_PATH_ROOT.'data/other/user.xml');
        $USR = stripslashes($datau->USR);
    } else {
        $USR = null;    
    }
    
    if (file_exists($INC_PATH_ROOT.'data/other/authorization.xml')) {
        $dataa = getXML($INC_PATH_ROOT.'data/other/authorization.xml');
        $SALT = stripslashes($dataa->apikey);
    } else {
        $SALT = sha1($USR);
    }

    // if there is no siteurl set, redirect user to install setup
    if (get_filename_id() != 'install' && get_filename_id() != 'setup') {
        if (@$SITEURL == '') {
            header('Location: '.$INC_PATH_ROOT.'admin/install.php');
            exit;
        }
        if (file_exists($INC_PATH_ROOT.'admin/install.php')) {
            unlink($INC_PATH_ROOT.'admin/install.php');
        }
        if (file_exists($INC_PATH_ROOT.'admin/setup.php')) {
            unlink($INC_PATH_ROOT.'admin/setup.php');
        }
    }
    
    //set timezone if module is available
    if( function_exists('date_default_timezone_set') && ($TIMEZONE != '' || stripos($TIMEZONE, '--')) ) {
        date_default_timezone_set(@$TIMEZONE);
    }
    
    //set internationalization
    if($LANG != '') {
        include($INC_PATH_ROOT.'admin/lang/'.$LANG.'.php');
    } else {
        include($INC_PATH_ROOT.'admin/lang/en_US.php');
    }

?>
Reply
#11
^- you are wrong. Variables that are set inside of a file are instantly available in included files that are inside that file after variables are set. I've gotten it already setup.

Chris you also repeat a lot of code, programming is so you don't have to do that.. There are a lot of repeated language setups. Like in login, you don't need it.
http://nijikokun.com
random stuff. idk.
Reply
#12
Nijikokun Wrote:Chris you also repeat a lot of code, programming is so you don't have to do that.. There are a lot of repeated language setups. Like in login, you don't need it.


I know I did... I originally created GS as a quick project then kept adding to it. I didn't sit down and draw up a design document because I wasnt releasing it as a publicly supported app... it just sort of grew into that. Maybe these changes need to be thought out a little more so we can sit down and draw it up correctly. I agree with many points here, but i don't think that so close to the 2.0 launch we need to change things around so drastically...

It works now, maybe not completely efficient, but that is something we can fix once 2.0 is out and mature. 2.0 should give people a stable great little CMS. I am hoping that maybe at 3.0 we can start introducing a new and improved (read: efficient) infrastructure. If we just get the constants right in 2.0, then no plugins will need to change after the infrastructure change.

Does this make sense? If we try and rewrite a ton of code now, 2.0 will not get out for quite some time.
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#13
I'm over 60% done with the rewrite of 2.0b surrounding a common file~
http://nijikokun.com
random stuff. idk.
Reply
#14
Thanks. I'm open to implementing any changes that test out OK. Send me the whole code via email so the team and I can take a look at it as well and test.
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#15
Alright, I'll do it once I'm sure Its done, and honestly, it makes me a lot happier the way I have it.
http://nijikokun.com
random stuff. idk.
Reply
#16
Nijikokun Wrote:honestly, it makes me a lot happier the way I have it.
and that is obviously all that matters Wink
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#17
How come we can't define the folders like some other scripts?

IE

$admin_folder = http://domain.com/admin/
$admin_inc_folder = http://domain.com/admin/inc/
$site_folder = http://domain.com/

All that can be dynamically written and put in the common.php file. Then if you call a script, reference the folder it is in.
IE, the uploadify script uploads to the data/uploads/ folder so you could reference something like this...

$uploading = $data_upload.'__FILE__'; // you get the point.
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply
#18
internet54 Wrote:How come we can't define the folders like some other scripts?

This has been added into 2.0 beta3, here is what I have so far:
Code:
define('GSROOTPATH', get_root_path());
define('GSADMINPATH', get_admin_path());
define('GSADMININCPATH', get_admin_path(). 'inc/');
define('GSDATAOTHERPATH', get_root_path(). 'data/other/');
define('GSDATAPAGESPATH', get_root_path(). 'data/pages/');
define('GSDATAUPLOADPATH', get_root_path(). 'data/uploads/');
define('GSBACKUPSPATH', get_root_path(). 'backups/');
define('GSTHEMESPATH', get_root_path(). 'theme/');
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply




Users browsing this thread: 1 Guest(s)