og_blueprint Class Reference

Inheritance diagram for og_blueprint:

Inheritance graph
[legend]

List of all members.


Detailed Description

Definition at line 84 of file og_blueprints.module.


Public Member Functions

 __call ($method, $args=NULL)
 __construct ($args)
 Load a blueprint.
 __get ($member)

Public Attributes

 $bid
 $bpid
 $bpname
 $default_page
 $did
 $enabled
 $linked
 $page_title
 $path
 $published
 $show_blocks
 $vid
 $weight

Protected Member Functions

 export ()
 insert ($args=NULL)
 load ($args)

Private Member Functions

 write_to_db ($op, $args)

Private Attributes

 $content_types
 $context
 $display
 $grouptype

Member Function Documentation

og_blueprint::__call ( method,
args = NULL 
)

Definition at line 162 of file og_blueprints.module.

00162                                                 {
00163     switch ($method) {
00164       case 'propagate':
00165       case 'save':
00166         $this->write_to_db('update', !empty($args) ? $args : array('bid', 'vid', 'bpid', 'did', 'linked', 'enabled', 'published', 'default_page', 'page_title', 'show_blocks', 'path', 'weight'));
00167         break;
00168 
00169       case 'propagate':
00170         $result = db_query("SELECT vid, bid FROM {og_bundle}");
00171         while ($row = db_fetch_array($result)) {
00172           list ($this->vid, $this->bid) = array_values($row);
00173           $this->write_to_db('update', $args);
00174         }
00175         break;
00176         
00177       case 'delete':
00178         $did_data = db_query("SELECT DISTINCT(bp.did) FROM {og_bundle} AS b INNER JOIN {og_bundle_revision} AS r ON b.vid = r.vid INNER JOIN {og_blueprint} AS bp ON b.vid = bp.vid WHERE bpid = %d");
00179         while ($did = db_fetch_array($did_data)) {
00180           panels_delete_display($did);
00181         }
00182         db_query("DELETE bp FROM {og_bundle} AS b INNER JOIN {og_bundle_revision} AS r ON b.vid = r.vid INNER JOIN {og_blueprint} AS bp ON b.vid = bp.vid WHERE bpid = %d", $this->bpid);
00183     }
00184   }

og_blueprint::__construct ( args  ) 

The constructor dynamically determines the method for loading the blueprint based on which args are passed in.

Parameters:
array $args An associative array of known blueprint values keyed by the respective field names of those values.

Reimplemented in og_blueprint_master.

Definition at line 95 of file og_blueprints.module.

00095                                      {
00096     foreach ($args as $field => $value) {
00097       $this->$field = $value;
00098     }
00099     $this->load($args);
00100   }

og_blueprint::__get ( member  ) 

Definition at line 191 of file og_blueprints.module.

00191                           {
00192     if (isset($this->$member)) {
00193       return $this->$member;
00194     }
00195     switch ($member) {
00196       case 'display':
00197       case 'context':
00198         panels_load_include('plugins');
00199         $this->display = panels_load_display($this->did);
00200         $this->context = $this->display->context = array('og_panels' => panels_context_create_empty('group'));
00201         return $member == 'display' ? $this->display : $this->context;
00202 
00203       case 'content_types':
00204         panels_load_include('common');
00205         return $this->content_types = $this->display->content_types = panels_common_get_allowed_types('og_panels', $this->context);
00206 
00207       case 'grouptype':
00208         return $this->grouptype = db_result(db_query("SELECT grouptype FROM {og_bundle} WHERE bid = %d", $this->bid));
00209 
00210     }
00211   }

og_blueprint::export (  )  [protected]

Definition at line 125 of file og_blueprints.module.

00125                               {
00126     $code = panels_export_display(panels_load_display($this->did));
00127     eval($code);
00128     panels_save_display($display);
00129     $this->did = $display->did;
00130   }

og_blueprint::insert ( args = NULL  )  [protected]

Definition at line 186 of file og_blueprints.module.

00186                                           {
00187     $this->write_to_db('insert', !is_null($args) ? $args : array('bid', 'vid', 'bpid', 'bpname', 'did', 'linked', 'enabled', 'published', 'default_page', 'page_title', 'show_blocks', 'path'));
00188   }

og_blueprint::load ( args  )  [protected]

Reimplemented in og_blueprint_release.

Definition at line 102 of file og_blueprints.module.

00102                                  {
00103     $fields = og_blueprints_query_fields();
00104     foreach ($args as $member => $value) {
00105       $fq[] = $member ." = ". $fields[$member];
00106       $v[] = $this->$member;
00107     }
00108     $string = preg_replace(array('/grouptype/', '/bid/', '/bpid/', '/vid/', '/did/'), array('b.grouptype', 'b.bid', 'bp.bpid', 'bp.vid', 'bp.did'), implode(' AND ', $fq));
00109     $blueprint = db_fetch_array(db_query(<<<QUERY
00110     SELECT
00111     b.bid, b.grouptype,
00112     r.vid,
00113     bp.bpid, bp.bpname, bp.did, bp.linked, bp.enabled, bp.published, bp.default_page, bp.page_title, bp.path, bp.show_blocks, bp.weight
00114     FROM {og_blueprint} AS bp
00115     LEFT JOIN {og_bundle_revision} AS r ON bp.vid = r.vid
00116     LEFT JOIN {og_bundle} AS b ON bp.bid = b.bid
00117     WHERE $string
00118 QUERY
00119     , $v));
00120     foreach ($blueprint as $field => $value) {
00121       $this->$field = $value;
00122     }
00123   }

og_blueprint::write_to_db ( op,
args 
) [private]

Definition at line 132 of file og_blueprints.module.

00132                                            {
00133     $args = og_blueprints_query_fields($args);
00134     switch ($op) {
00135       case 'update':
00136         // ONLY allow db manipulation if we're on the current version.
00137         if ($this->bid == db_result(db_query("SELECT DISTINCT b.bid FROM {og_bundle} AS b LEFT JOIN {og_blueprint} AS bp ON b.vid = bp.vid WHERE bp.vid = %d", $this->vid))) {
00138           foreach ($args as $member => $query_sub) {
00139             if (in_array($member, array('bpid', 'bid', 'vid', 'bpname'))) {
00140               list($f[], $q[], $vw[]) = array($member, $query_sub, $this->$member);
00141               continue;
00142             }
00143             list($fsq[], $v[]) = array($member ." = ". $query_sub, $this->$member);
00144           }
00145           db_query("UPDATE {og_blueprint} SET ". implode(' , ', $fsq) ." WHERE (". implode(' , ', $f) .") = (". implode(' , ', $q) .")", array_merge($v, $vw));
00146         }
00147         break;
00148 
00149       case 'insert':
00150         foreach ($args as $member => $query_sub) {
00151           if (isset($this->$member)) {
00152             $f[] = $member;
00153             $q[] = $query_sub;
00154             $v[] = $this->$member;
00155           }
00156         }
00157         db_query('INSERT INTO {og_blueprint} (' . implode(' , ', $f) . ') VALUES (' . implode(', ', $q) . ')', $v);
00158         break;
00159     }
00160   }


Member Data Documentation

og_blueprint::$bid

Definition at line 85 of file og_blueprints.module.

og_blueprint::$bpid

Definition at line 85 of file og_blueprints.module.

og_blueprint::$bpname

Definition at line 85 of file og_blueprints.module.

og_blueprint::$content_types [private]

Definition at line 86 of file og_blueprints.module.

og_blueprint::$context [private]

Definition at line 86 of file og_blueprints.module.

og_blueprint::$default_page

Definition at line 85 of file og_blueprints.module.

og_blueprint::$did

Definition at line 85 of file og_blueprints.module.

og_blueprint::$display [private]

Definition at line 86 of file og_blueprints.module.

og_blueprint::$enabled

Definition at line 85 of file og_blueprints.module.

og_blueprint::$grouptype [private]

Definition at line 86 of file og_blueprints.module.

og_blueprint::$linked

Definition at line 85 of file og_blueprints.module.

og_blueprint::$page_title

Definition at line 85 of file og_blueprints.module.

og_blueprint::$path

Definition at line 85 of file og_blueprints.module.

og_blueprint::$published

Definition at line 85 of file og_blueprints.module.

og_blueprint::$show_blocks

Definition at line 85 of file og_blueprints.module.

og_blueprint::$vid

Definition at line 85 of file og_blueprints.module.

og_blueprint::$weight

Definition at line 85 of file og_blueprints.module.


The documentation for this class was generated from the following file:

Generated on Sun May 18 20:36:51 2008 for Organic Groups Blueprints by  doxygen 1.5.5