We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    OK, now that I’ve actually started writing the readme.txt file, I’m confused again about the file locations.

    I have the class file (modmollom.class.php).
    I have the support library for that (IXR_Library.inc.php.txt).
    And I have the readme.txt file and two demo snippet files (mollomtest.php & mollomtest.css).

    People will probably use the demo snippet and will run it to see how things work, but won’t use it in real life - they’ll just use the service class.

    The class file goes in core/model/modx/mollom -- that’s a given, I think.

    Per your suggestion, the library file would go in /core/model/mollom/

    I’m thinking the snippet and css files would be in components/mollom

    And the readme.txt file could go in /core/model/mollom/ or components/mollom? I could make a case for either one.

    It seems wrong to put the files in three different places. Obviously, I can put them anywhere as long as I document it, but I’d like to make them easy for people to find without having to read the code. In 0.9.6, they’ll all be in assets/snippets/mollom/ which makes life much easier for developers learning to using the class. One of the points of resistance to Revo, IMHO, is that it’s hard to find things. It took me months to know where to look for things without consulting Shaun’s guide to the Revo directory structure. Similarly, it’s hard for developers to know where to put things, and I could still use some advice on where to put these files. (Admittedly, this is kind of an odd case and most add-ons should be easier to organize).

    I had trouble understanding Smarty at one point because the files weren’t all in one place, or even in the same path. I’m not sure that mirroring that with the other addons will be an improvement.







      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 22303 MODX Staff
      • 10,725 Posts
      Then I’d just put it all in a mollum package except the css file since it is a web resource; everything else belongs in/with the model, including the class file, the includes, the readme.txt and any demo .php files which really should not be exposed to the web server (to avoid accidental security holes like occured with reflect).

      So mollum would be the package and the model location should be configurable when they install, defaulting to MODX_CORE_PATH . ’model/’
        • 3749
        • 24,544 Posts
        Ok, that makes sense. Sorry for being so slow in this.

        The more I think about it, the more I’m not sure this package should really be a service (the same goes for captcha).

        Maybe I’m still misunderstanding services, but it seems to me that the main requirement for service-worthiness would be:

        1. Likely to be used by more than one component on the same page.

        (The mollom class doesn’t really qualify here. People will make multiple function calls on the same page, but the mollom object would persist across them. )

        Most of the other advantages you mention, it seems to me, could all be accomplished by just having a component class with some static member variables and pass it a reference to & $modx in the constructor. It’s trickier in PHP4 but, I think, still practical.

        With respect to security, it gets more complicated. Putting the example .php file in the core only protects it if the core is outside the web root. Many *components* might have a .php file, either for inclusion or as an example (almost all do in 0.9.6). We could have people put the components dir. outside the web root. I’m not sure how many people would do it. Frankly, I wonder how many people will actually put the *core* dir. outside the web root, even though we’ve made it possible. Maybe renaming the .php files to .php.txt isn’t such a bad idea after all, or putting die(’Remove this before use’); as the first line.

        Nothing in PHP ever survives a page load. To persist objects or data across page loads, you can use PHP sessions, files, a custom database table, or modRegistry.

        Um ... These two statements are somewhat contradictory. wink I knew that, I was just wondering if MODx might be stashing the service object somewhere. I should have made my question clearer.

        PS: It’s mollom, not mollum. wink It’s a palindrome, but before I knew that, I made the same mistake a bunch of times (in the code, where it counts double against you). wink

          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 28215
          • 4,149 Posts
          Just my two cents - I put my custom components solely in their own directories (all of them. I know. Jason and I argue about this. tongue)

          Quote from: BobRay at Feb 16, 2009, 12:46 PM

          With respect to security, it gets more complicated. Putting the example .php file in the core only protects it if the core is outside the web root. Many *components* might have a .php file, either for inclusion or as an example (almost all do in 0.9.6). We could have people put the components dir. outside the web root. I’m not sure how many people would do it. Frankly, I wonder how many people will actually put the *core* dir. outside the web root, even though we’ve made it possible. Maybe renaming the .php files to .php.txt isn’t such a bad idea after all, or putting die(’Remove this before use’); as the first line.

          Just fyi, if you do rename .php to .php.txt, those files will be readable from the browser. So make sure nothing sensitive is in those files, like passwords, keys, etc.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 3749
            • 24,544 Posts
            Quote from: splittingred at Feb 16, 2009, 12:52 PM

            Just my two cents - I put my custom components solely in their own directories (all of them. I know. Jason and I argue about this. tongue)
            Do you mean in MODX_BASE_PATH . ’components/’ ?


            Just fyi, if you do rename .php to .php.txt, those files will be readable from the browser. So make sure nothing sensitive is in those files, like passwords, keys, etc.

            Good tip. I try not to put anything sensitive in a any file.

            Hmm . . . I wonder if giving them an arbitrary extension (.inc?) and having .htacces send those files to a non-existent application or an application we provide that just returned an arbitrary string (or nothing) would work.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 28215
              • 4,149 Posts
              Quote from: BobRay at Feb 16, 2009, 01:03 PM

              Do you mean in MODX_BASE_PATH . ’components/’ ?
              Correct. Completely self-contained. You can go either route - that is, in essence, the flexibility of Revo.

              Jason would argue for the processors and includes going in the core, and web resources going in assets/components/, and his points make sense. I argue that it’s easier to manage files and contain problems if they’re all in one directory. It’s your choice, in the end, anyway.
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 3749
                • 24,544 Posts
                Uh oh.

                All my components install in MODX_BASE_PATH . ’/components/’ because *somebody* edited the captcha build file to put it there and I took it as a standard. wink

                Now you’re telling me ’assets/components/’ huh

                Is it time to redo all of them (Arghh sad)?
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 28215
                  • 4,149 Posts
                  Quote from: BobRay at Feb 16, 2009, 01:34 PM

                  Uh oh.
                  All my components install in MODX_BASE_PATH . ’/components/’ because *somebody* edited the captcha build file to put it there and I took it as a standard. wink
                  Now you’re telling me ’assets/components/’ huh
                  Actually, the build file says:

                  "return MODX_ASSETS_PATH . ’/components/’;"

                  which is, assets/components.

                  :P
                    shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                    • 3749
                    • 24,544 Posts
                    Quote from: splittingred at Feb 16, 2009, 02:11 PM

                    Quote from: BobRay at Feb 16, 2009, 01:34 PM

                    Uh oh.
                    All my components install in MODX_BASE_PATH . ’/components/’ because *somebody* edited the captcha build file to put it there and I took it as a standard. wink
                    Now you’re telling me ’assets/components/’ huh
                    Actually, the build file says:

                    "return MODX_ASSETS_PATH . ’/components/’;"

                    which is, assets/components.

                    :P

                    Whew! embarrassed
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 22303 MODX Staff
                      • 10,725 Posts
                      That should be:

                      "return MODX_ASSETS_PATH . 'components/';"


                      That extra slash could cause problems in some environments.