Author Topic: Digital Text CMS  (Read 49915 times)

0 Members and 1 Guest are viewing this topic.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Digital Text CMS (Continued from AC discussion)
« Reply #30 on: December 08, 2005, 02:34:46 am »
I thought PHP5 had this *shrug* that's not widely used anyhow.

I was in an especially tight bind because some of my classes take params in thier constructors which are essential to how it's run (example: $DB = new dtDatabase($settings['dbtype']) and settings is $settings = GetSettings();) and I had no idea how to pass that from config.php to the core to the module so globals worked perfectly here.

I was also faced with a setback because I was previously using array_push() but I don't think it can push associative arrays. Oh well I use a (imho) cleaner method now.

I think most of the major coding of the CMS is done though :)

RTFM.  Just kidding.  implements is a widely used OO structure in other OOP languages, just look at some of the Java code from JavaOp or something.

Yeah, other than passing them as params (which is really stupid to begin with), globals are the only way I'm aware of to share variables/objects between classes (unless you use a long line of extends classes, which is dumb anyway).

In my opinion, array_push is a pretty useless function.  As I'm sure you're aware, it has the same affect as:

Code: [Select]
$v = array();

v[] = '0';

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Digital Text CMS (Continued from AC discussion)
« Reply #31 on: December 08, 2005, 02:47:56 am »
Yea. Why would I want to read something on PHP5!? :P.

array_push() was getting annoying so while looking through some old advancedcontent code I saw I did it like this in some places (Saved by my old code!).

I like my current CMS' state it's pretty powerful yet small. I can't see any bugs in it (except some warnings PHP would generate if I do something withought checking another which I'll fix) all that I really lack is the time to sit down and write some modules.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Digital Text CMS (Continued from AC discussion)
« Reply #32 on: December 08, 2005, 01:46:43 pm »
Yea. Why would I want to read something on PHP5!? :P.

array_push() was getting annoying so while looking through some old advancedcontent code I saw I did it like this in some places (Saved by my old code!).

I like my current CMS' state it's pretty powerful yet small. I can't see any bugs in it (except some warnings PHP would generate if I do something withought checking another which I'll fix) all that I really lack is the time to sit down and write some modules.

Haha.  Its funny that they'd even have a function that can be replaced with an operator.  It's like having an add() function.  Oh well, haha.

That's what we call "efficient!" :P

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Digital Text CMS (Continued from AC discussion)
« Reply #33 on: December 08, 2005, 03:40:08 pm »
Okay I decided to keep my modules in this simplistic format maybe improve on it with some identification abilities (Make them able to inherit a class from thier own probably thier own class spawned on thier creation so they can identify themselves if they'd like but that would allow them to do evil things (Like include themselves endlessly but then again, who'd use a malicious module!?). Yea I'll probably do a little more thinking but for now I think I'll leave it this way.

I'm going to start working on some basic modules to show off the functionality of the core and get around to seeing if theres any optimizations I can make before releasing a stable "beta1"
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Digital Text CMS (Continued from AC discussion)
« Reply #34 on: December 08, 2005, 05:43:34 pm »
Okay I decided to keep my modules in this simplistic format maybe improve on it with some identification abilities (Make them able to inherit a class from thier own probably thier own class spawned on thier creation so they can identify themselves if they'd like but that would allow them to do evil things (Like include themselves endlessly but then again, who'd use a malicious module!?). Yea I'll probably do a little more thinking but for now I think I'll leave it this way.

I'm going to start working on some basic modules to show off the functionality of the core and get around to seeing if theres any optimizations I can make before releasing a stable "beta1"

If they'd like to?  You're making it sound like they have minds of their own!  Scary.

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Digital Text CMS (Continued from AC discussion)
« Reply #35 on: December 08, 2005, 05:51:30 pm »
Haha after rereading it is sorta scary. Anyhow I havn't implemented anything new yet but I was testing my modules and wrote a simple news one, here it is:

Code: [Select]
<?php
global 
$Disp;
global $DB;

$Display = new dtDisplay("news.tpl");

$action $_GET['action'];

switch ($action)
{
case "":
$query $DB->PerformQuery("SELECT * FROM site_news LIMIT 1");

if ($DB->GetRowCount($query) == 0)
{
$Disp->assign("News_Count"0);
} else {
$news_array = array();
$i 0;

while ($result $DB->FetchArray($query))
{
$news_array[$i]['Subject'] = $result['Subject'];
$news_array[$i]['Author'] = $result['Author'];
$news_array[$i]['Message'] = nl2br($result['Message']);
$i++;
}

$Display->assign("News_Count"$i);
$Display->assign("News_Item"$news_array);

}

$Disp->assign("Content"$Display->fetch("news.tpl"));
break;
}
?>

One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Digital Text CMS (Continued from AC discussion)
« Reply #36 on: December 08, 2005, 06:37:54 pm »
That is nice and clean. :)

Are you sure you don't want to have the modules outside of classes, though?  I'd probably recommend against that, but its your CMS, not mine. :)

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Digital Text CMS (Continued from AC discussion)
« Reply #37 on: December 09, 2005, 12:08:54 am »
They arn't really in classes. They just have access to essential classes if they want (I think the only "required" but not really required one is the Display class (to of course, display text in the content area).

Example: The module could just do some sort of internal action instead of displaying anything thus not using any classes. As I write more classes I can expose more. I was actually surprised $smarty->fetch() worked so well.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Digital Text CMS (Continued from AC discussion)
« Reply #38 on: December 09, 2005, 12:14:26 am »
Actually I realize I may have misled you so, the core creates a class for the module (which creates the entry in the mySQL if it doesn't exist then actually includes the module) but the module itself isn't a class.

Actually here's what it does (yes this needs a bit of work)

Code: [Select]
<?php
/* LiquidDev
Professional Scripting
   
   @author: Nelson Carrillo
 */

class dtModules
{

function SetModule($mod)
{

if (!$this->Exists($mod))
$this->Create($mod);

$this->Perform($mod);
}


function Exists($mod)
{
$settings GetSettings();
$DB = new dtDatabase($settings['dbtype']);

$query "SELECT * FROM site_mods WHERE ModName='" $mod "'";

if ($DB->GetRowCount($DB->PerformQuery($query)) == 0)
return false;
else
return true;
}

function Create($mod)
{
$settings GetSettings();
$DB = new dtDatabase($settings['dbtype']);

$query $DB->PerformQuery("INSERT INTO site_mods SET ModName='" $mod "'");

// TODO: Check the query.

return;
}

function Perform($mod)
{
include_once("modules/" $mod "/index.php"); // TODO: Check to make sure this file exists!
}
}

?>

One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Digital Text CMS (Continued from AC discussion)
« Reply #39 on: December 09, 2005, 01:08:46 am »
No, I mean that you're not wrapping the module itself in a class of its own?  Something like:

Code: [Select]
<?php

class module extends dtModules {
  function 
do_this()
    ...
}

?>

Maybe I'm missing something?

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Digital Text CMS (Continued from AC discussion)
« Reply #40 on: December 09, 2005, 01:25:56 am »
No I'm not doing something like that. I did something like that before and didn't like it. It created a problem with instancing classes and whatever. I may try it in the future but for now, no.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Digital Text CMS (Continued from AC discussion)
« Reply #41 on: December 09, 2005, 01:33:44 am »
No I'm not doing something like that. I did something like that before and didn't like it. It created a problem with instancing classes and whatever. I may try it in the future but for now, no.

Just do something like this:

Code: [Select]

class core {

 ...

 function load_module($mod) {
   include_once('modoules/'. $mod .'/index.php');

   $mod->load();
 }

}

// $mod/index.php:

class module extends core {

  function load() {
    ...
  }

}

$mod = new module();

Maybe that'll help?  Of course your way works nicely already, so changing it isn't necessarily a good idea. :)

}

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Digital Text CMS (Continued from AC discussion)
« Reply #42 on: December 09, 2005, 01:39:54 am »
I believe I had something like (I think I've shared it here before)

Code: [Select]
class MyModuleName extends MyCoreName
{
     function MyModuleName()
     {
           $settings['Author'] = "Nelson";
           $settings['Description'] = "This is a description";
           //...etc
          $this->RegisterModule($settings);

          return;
     }

// ...
}
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Digital Text CMS (Continued from AC discussion)
« Reply #43 on: December 09, 2005, 02:03:34 am »
I believe I had something like (I think I've shared it here before)

Code: [Select]
class MyModuleName extends MyCoreName
{
     function MyModuleName()
     {
           $settings['Author'] = "Nelson";
           $settings['Description'] = "This is a description";
           //...etc
          $this->RegisterModule($settings);

          return;
     }

// ...
}

This is the important part:

Code: [Select]
// $mod/index.php:

class module extends core {

  function load() {
    ...
  }

}

[b]$mod = new module();[/b]

That should eliminate your class instancing.

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Digital Text CMS (Continued from AC discussion)
« Reply #44 on: December 09, 2005, 02:15:45 am »
I might try it again later and see if I get any problems, it certainly is cleaner.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling