1
bingomanatee
Carpenter: self-writing class code for XOOPS

Check outhttp://www.wonderlandlabs.com/modules/wiwimod/index.php?page=CarpenterSqlApi&back=WebProduction

for self-writing mySQL classes. PHP 5.0 required.


* Dynamic Class Instantiation. Every time you change the database, Carpenter rewrites the core table and record classes "on the fly". Carpenter's two tier class base allows for a "superclass" over each "data class" that can be customized, so you don't lose custom code when the core class is overwritten. (you may have to rewrite custom code if your field names change, but that is pretty much unavoidable.)
* Complete encapsulation of SQL I/O. Records are created with !!MyTable!!->new_record(), saved with a simple save() (that either inserts or updates records) and can be loaded based on criteria with a !!MyTable!!->get_record($pCriteria) call. I rely a lot on XOOPS' excellent criteria class, which is a very flexible way to define a field based query, but straight text based SQL criteria work as well.
* Guaranteed uniqueness of record objects - as all record are created and loaded through the Table object, there is a 1:1 correlation on any given execution cycle between records and their representative objects. As far as I know it is impossible for one context to create, alter and save a record object while another context has a second object representing that same object with different field values. There is NOT an observbable pattern at work here; just a factory that registers all returned record objects.
* Utility relationship helpers: Extensions allow for magic methods to get child records or parent records or other associative data without having to manually add associative methods to each record or table class. Just add the appropriate relationship extension to a table superclass and your record class will magically acquire extra methods to facilitate relationships.
* Direct, filtered field properties: because the fields leverage the 5.0 "Magic" methods, you can refer to them by name. The table class will automatically filter field values based on field type, length, etc. in the background.
* Dynamic loading of table and record classes: Only the classes needed for any given round of execution are loaded in real time. Even though Carpenter generates code for every table in your database, the core database class allows you to load in real time the table and record classes you need without any include() code required on your part. This is again through the PHP 5.0 system.
* Allowance for un-indexed tables: Through using pre_save() code you can manually insert primary key values for records on the fly, that have not been set to auto-increment. This allows for instance SugarCRM-style indexes to be generated based on timestamps or what not for parallel databases or tables that are likely to hold huge numbers of records.
* Optional array-based retrieval of data: the core database allows for criteria based SQL calls that return arrays, single values, etc. so that you do not have to instantiate objects if you want to return a vast number of records, or an array of results with only limited fields etc. This is useful in reports or other situations where read-only, faster results are more important than getting your data in object form.

Note that Carpenter integrates with XOOPS' excellent Criteria system for writing queries. You can pass text based criteria but Carpenter also accepts Criteria objects in record retrival.



2
bingomanatee
FckEditor doesn't allow me to browse files

I am trying to get the "link" widget in FCKeditor to allow me to browse files.

I am using the FCKEditor that came with the editor class package, in wiwimod, under PHP 5.0

It currently allows me to upload a file but it claims (incorrectly) that I have set $Config['Enabled'] to false (when it is true), in the connector/php/config.php file and in the config.js file in the FCKeditor root.

Just to see what happens I commented out the whole block

and it starts giving me XML server not available messages.



3
bingomanatee
Re: Q: why can't I upload images through FCKeditor? A: ...

I can't find the fckeditor.connector.php files anywhere or references on how to get/make them; any suggestions?

Dave



4
bingomanatee
Re: Complete Criteria Class

I originally modified the Criteria objects before fully understanding their implmentation in XOOPS. Since there are rationale (if not an absolute requirement) for separating the limit and sort fields in XOOPS you can't really do that.

So I have written an extension class for CriteriaCompo that effects the same thing. Note that I am working in PHP 5.0 and so have not tested this on 4.x platforms.

Note also that this will cascade functionally to renderWhere() and renderLdap() execution. As I am not Ldap-educated I can't really say how appropriate this is.

<?

/*********************
 * 
 * The classic Criteria classes are designed to split the load 
 * of the SQL generation with the calling code; specifically leveraging off 
 * of the db_query's limit oriented parameters. 
 * Criteria_sort_limit and Criteria_sort_limit_compo 
 * generates all the required SQL for the selection. 
 *
 */

require_once('criteria.php');


class 
Criteria_sort_limit extends Criteria 
{
  function 
render()
  {
    
$ret parent::render();
    
    if (
$this->getSort())
    {
        
$ret .= " ORDER BY {$this->getSort()} {$this->getOrder()} ";
    }
    
    if (
$this->getLimit())
    {
        if (
$this->getStart())
        {
            
$ret .= " LIMIT {$this->getLimit()} OFFSET {$this->getStart()} ";
        }
        else 
        {
            
$ret .= " LIMIT {$this->getLimit()} ";            
        }
    }
    else
    {
        
// mySQL syntax is not amenable to an unlimited start offset
    
}
    
    return 
$ret;
  }  
}

class 
Criteria_sort_limit_compo extends CriteriaCompo 
{
  function 
render()
  {
    
$ret parent::render();
    
    if (
$this->getSort())
    {
        
$ret .= " ORDER BY {$this->getSort()} {$this->getOrder()} ";
    }
    
    if (
$this->getLimit())
    {
        if (
$this->getStart())
        {
            
$ret .= " LIMIT {$this->getLimit()} OFFSET {$this->getStart()} ";
        }
        else 
        {
            
$ret .= " LIMIT {$this->getLimit()} ";            
        }
    }
    else
    {
        
// mySQL syntax is not amenable to an unlimited start offset
    
}
    
    return 
$ret;
  }
}

?>



5
bingomanatee
Complete Criteria Class

One thing I noticed about the Criteria class suite is that it has incomplete support for the order and limit functions of SQL. It has properties for these syntax elements but they don't render.

-- SAMPLE DELETED BY AUTHOR --



6
bingomanatee
controlling debug mode in page context

I am developing a module that pulls in pages ajax-style.

I want the main pages I'm still working on to have deug flags (time, errors, smarty messages etc.) but to be able to "Turn off" these error flags on ajax-inserted questions.

How can I write code to turn off (or perhaps on!) the debug mode on a page by page basis?



7
bingomanatee
Trying to set up a remote host

I am developing an install on a remote host; what is the proper value for a host name in this case? I am presuming XOOPS supports remote hosting?

we have tried the host name and the ip address; neither case is working for us.



8
bingomanatee
Re: XoopsZipDownloader

I have applied your patch and I still get the message (from the OS after downloading the ZIP:)

"The archive is corrupted and cannot be read."

Any suggestions?

Thanks... Dave




TopTop



Login

Who's Online

201 user(s) are online (119 user(s) are browsing Support Forums)


Members: 0


Guests: 201


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits