示例#1
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $attributes = array();
     foreach ($node->attributes() as $k => $v) {
         if ($v != '') {
             $attributes[$k] = (string) $v;
         }
     }
     /*
      * Required to avoid a cycle of encoding &
      * html_entity_decode was used in place of htmlspecialchars_decode because
      * htmlspecialchars_decode is not compatible with PHP 4
      */
     $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES), ENT_QUOTES);
     $attributes['class'] = (string) $node->attributes()->class ? (string) $node->attributes()->class . ' text_area' : 'text_area';
     $control = $control_name . '[' . $name . ']';
     $html = '';
     $attributes['value'] = $value;
     $attributes['type'] = 'text';
     $attributes['name'] = $control;
     $attributes['id'] = preg_replace('#[^a-z0-9_-]#i', '', $control_name . $name);
     // pattern data attribute for editable select input box
     if ((string) $node->attributes()->parent) {
         $prefix = preg_replace(array('#^params#', '#([^\\w]+)#'), '', $control_name);
         $items = array();
         foreach (explode(';', (string) $node->attributes()->parent) as $item) {
             $items[] = $prefix . $item;
         }
         $attributes['data-parent'] = implode(';', $items);
     }
     $filter = isset($attributes['data-filter']) ? $attributes['data-filter'] : '';
     $html .= '<input';
     foreach ($attributes as $k => $v) {
         if (!in_array($k, array('default', 'label', 'description'))) {
             $html .= ' ' . $k . ' = "' . $v . '"';
         }
     }
     $html .= ' />';
     $component = WFExtensionHelper::getComponent();
     // get params definitions
     $params = new WFParameter($component->params, '', 'preferences');
     $width = (int) $params->get('browser_width', 780);
     $height = (int) $params->get('browser_height', 560);
     wfimport('admin.models.model');
     $model = new WFModel();
     $link = $model->getBrowserLink($attributes['id'], $filter);
     $html .= '<a href="' . $link . '" id="' . $attributes['id'] . '_browser' . '" class="browser" target="_blank" onclick="Joomla.modal(this, \'' . $link . '\', ' . $width . ', ' . $height . ');return false;" title="' . WFText::_('WF_BROWSER_TITLE') . '"><span class="browser"></span></a>';
     return $html;
 }
示例#2
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     $client = JRequest::getWord('client', 'admin');
     $model = $this->getModel();
     $this->document->setTitle(WFText::_('WF_PREFERENCES_TITLE'));
     $this->document->addStyleSheet('templates/system/css/system.css');
     $component = WFExtensionHelper::getComponent();
     $xml = JPATH_COMPONENT . '/models/preferences.xml';
     // get params definitions
     $params = new WFParameter($component->params, $xml, 'preferences');
     $params->addElementPath(JPATH_COMPONENT . '/elements');
     if (WFModel::authorize('admin')) {
         $form = $model->getForm('permissions');
     } else {
         $form = null;
     }
     $this->assign('params', $params);
     $this->assign('permissons', $form);
     $this->addStyleSheet('components/com_jce/media/css/preferences.css');
     $this->addScript('components/com_jce/media/js/preferences.js');
     if (JRequest::getInt('close') == 1) {
         $this->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Preferences.close();});');
     } else {
         $this->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Preferences.init();});');
     }
     parent::display($tpl);
 }
示例#3
0
 function display($tpl = null)
 {
     wfimport('admin.models.updates');
     $mainframe = JFactory::getApplication();
     $model = $this->getModel();
     $version = $model->getVersion();
     $component = WFExtensionHelper::getComponent();
     // get params definitions
     $params = new WFParameter($component->params, '', 'preferences');
     $canUpdate = WFModelUpdates::canUpdate() && WFModel::authorize('installer');
     $options = array('feed' => (int) $params->get('feed', 0), 'updates' => (int) $params->get('updates', $canUpdate ? 1 : 0), 'labels' => array('feed' => WFText::_('WF_CPANEL_FEED_LOAD'), 'updates' => WFText::_('WF_UPDATES'), 'updates_available' => WFText::_('WF_UPDATES_AVAILABLE')));
     JHtml::_('behavior.modal');
     $this->addScript('components/com_jce/media/js/cpanel.js');
     $this->addScriptDeclaration('jQuery.jce.Cpanel.options = ' . json_encode($options) . ';');
     // load styles
     $this->addStyleSheet(JURI::root(true) . '/administrator/components/com_jce/media/css/cpanel.css');
     if (WFModel::authorize('preferences')) {
         WFToolbarHelper::preferences();
     }
     if (WFModel::authorize('installer')) {
         WFToolbarHelper::updates($canUpdate);
     }
     WFToolbarHelper::help('cpanel.about');
     $views = array('config', 'profiles', 'installer', 'browser', 'mediabox');
     $icons = array();
     foreach ($views as $view) {
         // check if its allowed...
         if (WFModel::authorize($view) === false) {
             continue;
         }
         $attribs = array('target="_self"');
         $title = 'WF_' . strtoupper($view);
         $description = 'WF_' . strtoupper($view) . '_DESC';
         $link = 'index.php?option=com_jce&amp;view=' . $view;
         if ($view == 'browser') {
             $link = WFModel::getBrowserLink();
             $component = WFExtensionHelper::getComponent();
             // get params definitions
             $params = new WFParameter($component->params, '', 'preferences');
             $width = (int) $params->get('browser_width', 790);
             $height = (int) $params->get('browser_height', 560);
             if (empty($link)) {
                 continue;
             }
             $attribs = array('target="_blank"', 'class="browser"', 'onclick="Joomla.modal(this, \'' . $link . '\', ' . $width . ', ' . $height . ');return false;"');
             $title = 'WF_' . strtoupper($view) . '_TITLE';
             $description = 'WF_CPANEL_' . strtoupper($view);
         }
         // if its mediabox, check the plugin is installed and enabled
         if ($view == 'mediabox' && !JPluginHelper::isEnabled('system', 'jcemediabox')) {
             continue;
         }
         $icons[] = '<li class="cpanel-icon wf-tooltip" title="' . WFText::_($title) . '::' . WFText::_($description) . '"><a id="wf-browser-link" href="' . $link . '"' . implode(' ', $attribs) . '><span class="' . $view . '"></span>' . WFText::_($title) . '</a></li>';
     }
     $this->assign('icons', $icons);
     $this->assign('model', $model);
     $this->assign('params', $params);
     $this->assign('version', $version);
     parent::display($tpl);
 }
 public function onGetIcons($context)
 {
     @(include_once JPATH_ADMINISTRATOR . '/components/com_jce/models/model.php');
     // check for class to prevent fatal errors
     if (!class_exists('WFModel')) {
         return;
     }
     if ($context != $this->params->get('context', 'mod_quickicon') || WFModel::authorize('browser') === false) {
         return;
     }
     $document = JFactory::getDocument();
     $language = JFactory::getLanguage();
     $language->load('com_jce', JPATH_ADMINISTRATOR);
     $width = $this->params->get('width', 800);
     $height = $this->params->get('height', 600);
     $filter = $this->params->get('filter', '');
     JHtml::_('behavior.modal');
     $document->addScriptDeclaration("\n\t\twindow.addEvent('domready', function() {\n\t\t\tSqueezeBox.assign(\$\$('#plg_quickicon_jcefilebrowser a'), {\n\t\t\t\thandler: 'iframe', size: {x: " . $width . ", y: " . $height . "}\n\t\t\t});\n\t\t});");
     require_once JPATH_ADMINISTRATOR . '/components/com_jce/helpers/browser.php';
     $version = new JVersion();
     $icon = $version->isCompatible('3.0') ? 'pictures' : 'header/icon-48-media.png';
     $link = WFBrowserHelper::getBrowserLink('', $filter);
     if ($link) {
         return array(array('link' => $link, 'image' => $icon, 'icon' => 'pictures', 'access' => array('jce.browser', 'com_jce'), 'text' => JText::_('WF_QUICKICON_BROWSER'), 'id' => 'plg_quickicon_jcefilebrowser'));
     }
     return array();
 }
示例#5
0
 function sharedModel()
 {
     if (!self::$_instance) {
         self::$_instance = new WFModel();
     }
     return self::$_instance;
 }
示例#6
0
文件: browser.php 项目: 01J/bealtine
 function fetchElement($name, $value, &$node, $control_name)
 {
     $attributes = array();
     foreach ($node->attributes() as $k => $v) {
         if ($v != '') {
             $attributes[$k] = (string) $v;
         }
     }
     /*
      * Required to avoid a cycle of encoding &
      * html_entity_decode was used in place of htmlspecialchars_decode because
      * htmlspecialchars_decode is not compatible with PHP 4
      */
     $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES), ENT_QUOTES);
     $attributes['class'] = (string) $node->attributes()->class ? (string) $node->attributes()->class . ' text_area' : 'text_area';
     $control = $control_name . '[' . $name . ']';
     $html = '';
     $attributes['value'] = $value;
     $attributes['type'] = 'text';
     $attributes['name'] = $control;
     $attributes['id'] = preg_replace('#[^a-z0-9_-]#i', '', $control_name . $name);
     // pattern data attribute for editable select input box
     if ((string) $node->attributes()->parent) {
         $prefix = preg_replace(array('#^params#', '#([^\\w]+)#'), '', $control_name);
         $items = array();
         foreach (explode(';', (string) $node->attributes()->parent) as $item) {
             $items[] = $prefix . $item;
         }
         $attributes['data-parent'] = implode(';', $items);
     }
     $filter = isset($attributes['data-filter']) ? $attributes['data-filter'] : '';
     $html .= '<input';
     foreach ($attributes as $k => $v) {
         if (!in_array($k, array('default', 'label', 'description'))) {
             $html .= ' ' . $k . ' = "' . $v . '"';
         }
     }
     $html .= ' />';
     $options = array('width' => 780, 'height' => 560, 'modal' => true, 'id' => $attributes['id'] . '_browser');
     wfimport('admin.models.model');
     $model = new WFModel();
     $html .= '<a href="' . $model->getBrowserLink($attributes['id'], $filter) . '" class="dialog browser" target="_blank" data-options="' . str_replace('"', "'", json_encode($options)) . '" title="' . WFText::_('WF_BROWSER_TITLE') . '"><span class="browser"></span></a>';
     return $html;
 }
示例#7
0
 function display($tpl = null)
 {
     wfimport('admin.models.updates');
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $state = $model->getState();
     $layout = JRequest::getWord('layout', 'install');
     $plugins = '';
     $extensions = '';
     $languages = '';
     JHtml::_('behavior.modal');
     if (WFModel::authorize('uninstall')) {
         WFToolbarHelper::deleteList('', 'remove', 'WF_INSTALLER_UNINSTALL');
     }
     WFToolbarHelper::updates(WFModelUpdates::canUpdate());
     WFToolbarHelper::help('installer.about');
     $options = array('extensions' => array('zip', 'tar', 'gz', 'gzip', 'tgz', 'tbz2', 'bz2', 'bzip2'), 'width' => 300, 'button' => 'install_button', 'task' => 'install', 'iframe' => false, 'labels' => array('browse' => WFText::_('WF_LABEL_BROWSE'), 'alert' => WFText::_('WF_INSTALLER_FILETYPE_ERROR')));
     $this->addScript('components/com_jce/media/js/installer.js');
     $this->addScript('components/com_jce/media/js/uploads.js');
     $this->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Installer.init(' . json_encode($options) . ');});');
     // load styles
     $this->addStyleSheet(JURI::root(true) . '/administrator/components/com_jce/media/css/installer.css');
     $state->set('install.directory', $app->getCfg('tmp_path'));
     $plugins = $model->getPlugins();
     $extensions = $model->getExtensions();
     $languages = $model->getLanguages();
     $related = $model->getRelated();
     $this->assign('plugins', $plugins);
     $this->assign('extensions', $extensions);
     $this->assign('languages', $languages);
     $this->assign('related', $related);
     $result = $state->get('install.result');
     $this->assign('showMessage', count($result));
     $this->assign('model', $model);
     $this->assign('state', $state);
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $this->assign('ftp', $ftp);
     $this->setLayout($layout);
     parent::display($tpl);
 }
示例#8
0
文件: browser.php 项目: grlf/eyedock
 public static function getBrowserLink($element = null, $filter = '')
 {
     require_once dirname(dirname(__FILE__)) . '/models/model.php';
     $model = new WFModel();
     return $model->getBrowserLink($element, $filter);
 }
示例#9
0
        </li>
        <li>
            <span class="wf-tooltip" title="<?php 
echo WFText::_('WF_CPANEL_VERSION') . '::' . WFText::_('WF_CPANEL_VERSION_DESC');
?>
">
<?php 
echo WFText::_('WF_CPANEL_VERSION');
?>
            </span>
                <?php 
echo $this->version;
?>
        </li>
            <?php 
if ($this->params->get('feed', 0) || WFModel::authorize('preferences')) {
    ?>
            <li>
                <span class="wf-tooltip" title="<?php 
    echo WFText::_('WF_CPANEL_FEED') . '::' . WFText::_('WF_CPANEL_FEED_DESC');
    ?>
">
    <?php 
    echo WFText::_('WF_CPANEL_FEED');
    ?>
                </span>
                <span style="display:inline-block;">
    <?php 
    if ($this->params->get('feed', 0)) {
        ?>
                        <ul class="newsfeed"><li><?php 
示例#10
0
 public function authorize($task)
 {
     wfimport('admin.models.model');
     if (WFModel::authorize($task) === false) {
         $this->setRedirect('index.php', WFText::_('ALERTNOTAUTH'), 'error');
         return false;
     }
     return true;
 }
示例#11
0
 /**
  * Create an object of Class with the passed name/value pairs.
  *
  * @param string The class of object to create.
  * @return object The instance created.
  * @throws object WFException
  */
 protected function makeObj($class, $props)
 {
     if (!is_array($props)) {
         throw new WFException("Class definition for {$class} doesn't have any properties. Properties must be defined in an array.");
     }
     $model = WFModel::sharedModel();
     $o = new $class();
     if ($o instanceof BaseObject) {
         // model object; could have relationships, see if we need to build it...
         if (!$model->getEntity($class)) {
             $model->buildModel($this->getOpt(self::OPT_MODEL_ADAPTER), NULL, array($class));
         }
         foreach ($props as $k => $v) {
             // is this an attribute or a relationship?
             $entity = $model->getEntity($class);
             if ($entity->getProperty($k)) {
                 // it's a basic property
                 if (!is_array($v)) {
                     // is $v a php eval?
                     $matches = array();
                     if (preg_match('/<\\?php (.*)\\?' . '>/', $v, $matches)) {
                         $v = eval("return {$matches[1]};");
                     }
                     $o->setValueForKey($v, $k);
                 } else {
                     // "value" for this key is an object.
                     if (count(array_keys($v)) != 1) {
                         throw new WFException("Fixtures can pass only scalars or objects. Arrays of object are not supported.");
                     }
                     $subClass = key($v);
                     $subClassProps = $v[$subClass];
                     $subObj = $this->makeObj($subClass, $subClassProps);
                     $o->setValueForKey($subObj, $k);
                 }
             } else {
                 // not a property, it is a relationship...
                 // see if we can get that relationship
                 if (!$model->getEntity($k)) {
                     // try to build the entity; can't get all relationships unless we build the related entity
                     try {
                         $model->buildModel($this->getOpt(self::OPT_MODEL_ADAPTER), NULL, array($k));
                     } catch (Exception $e) {
                         // maybe it's an instance variable or just a KVC property?
                         try {
                             // is $v a php eval?
                             $matches = array();
                             if (preg_match('/<\\?php (.*)\\?' . '>/', $v, $matches)) {
                                 $v = eval("return {$matches[1]};");
                             }
                             $o->setValueForKey($v, $k);
                             continue;
                         } catch (Exception $e) {
                             throw new WFException("{$k} is not a known Propel entity, nor is it a KVC method:" . $e->getMessage());
                         }
                     }
                 }
                 $rel = $entity->getRelationship($k);
                 if (!$rel) {
                     // maybe it's an instance variable or just a KVC property?
                     try {
                         // is $v a php eval?
                         $matches = array();
                         if (preg_match('/<\\?php (.*)\\?' . '>/', $v, $matches)) {
                             $v = eval("return {$matches[1]};");
                         }
                         $o->setValueForKey($v, $k);
                         continue;
                     } catch (Exception $e) {
                         throw new WFException("{$k} is not a manifested entity relationship or a KVC-compliant property of {$class}.");
                     }
                 }
                 if ($rel->valueForKey('toOne')) {
                     // check for "empty" object
                     if ($v === NULL) {
                         $v = array();
                     }
                     if (is_array($v)) {
                         // treat the obj as an "inline object"
                         $subObj = $this->makeObj($k, $v);
                     } else {
                         // we expect an object here. this could be either a named object or result of an eval
                         // is $v a php eval?
                         $matches = array();
                         if (preg_match('/<\\?php (.*)\\?>/', $v, $matches)) {
                             $subObj = eval("return {$matches[1]};");
                             if (!is_object($subObj)) {
                                 throw new WFException("Result of eval for relationship {$v} is not an object: " . $matches[1]);
                             }
                         } else {
                             if (!isset($this->objById[$k][$v])) {
                                 throw new WFException("No {$k} with label {$v}.");
                             }
                             $subObj = $this->objById[$k][$v];
                         }
                     }
                     $o->setValueForKey($subObj, $k);
                 } else {
                     foreach ($v as $index => $subClassProps) {
                         try {
                             // we expect an object here. this could be either a named object or result of an "inline" object via YAML
                             // if subClassProps is a string, it's the former.
                             if (is_string($subClassProps)) {
                                 if (!isset($this->objById[$k][$subClassProps])) {
                                     throw new WFException("Failed to find a named object of class {$k} with label {$subClassProps}.");
                                 }
                                 $subObj = $this->objById[$k][$subClassProps];
                             } else {
                                 $subObj = $this->makeObj($k, $v[$index]);
                             }
                         } catch (Exception $e) {
                             throw new WFException("Error processing {$index} class={$k}: " . $e->getMessage());
                         }
                         $toManyAdderF = "add" . $k;
                         $o->{$toManyAdderF}($subObj);
                         if (gettype($index) != 'integer') {
                             if (isset($this->objById[$k][$index])) {
                                 throw new Exception("There already exists a {$k} for id {$index}.");
                             }
                             $this->objById[$k][$index] = $subObj;
                         }
                     }
                 }
             }
         }
     } else {
         // simple object; has to contain key-value pairs.
         foreach ($props as $k => $v) {
             $o->setValueForKey($v, $k);
         }
     }
     return $o;
 }
示例#12
0
<?php

require_once getenv('PHOCOA_PROJECT_CONF');
if ($argc != 2) {
    die("Usage: scaffold.php 'entity1 entity2 ...'\n");
}
$adapter = 'Propel';
if (defined('ORM_MODEL_ADAPTER')) {
    $adapter = ORM_MODEL_ADAPTER;
}
$builder = 'WFModelCodeGenPropel';
$configFile = APP_ROOT . '/propel-build/phocoa-generator-config.yaml';
if (!file_exists($configFile)) {
    $configFile = NULL;
}
$delim = ' ';
if (strchr($argv[1], ',')) {
    $delim = ',';
}
$entities = array_map("trim", explode($delim, $argv[1]));
$model = WFModel::sharedModel();
$model->buildModel($adapter, $configFile, $entities);
foreach ($model->entities() as $entity) {
    $codeGen = new $builder();
    try {
        $codeGen->generateModuleForEntity($entity);
    } catch (Exception $e) {
        print "Error generating scaffold for entity '{$entity}': " . $e->getMessage() . "\n";
    }
}
<?php

// no direct access
defined('_JEXEC') or die('Restricted access');
$app = JFactory::getApplication();
// only in Admin and only if the component is enabled
if ($app->isSite() || JComponentHelper::getComponent('com_jce', true)->enabled === false) {
    return;
}
@(include_once JPATH_ADMINISTRATOR . '/components/com_jce/models/model.php');
// check for class to prevent fatal errors and authorize
if (!class_exists('WFModel') || WFModel::authorize('browser') === false) {
    return;
}
JHtml::_('behavior.modal');
require_once JPATH_ADMINISTRATOR . '/components/com_jce/helpers/browser.php';
$language = JFactory::getLanguage();
$language->load('com_jce', JPATH_ADMINISTRATOR);
$document = JFactory::getDocument();
$document->addStyleSheet('components/com_jce/media/css/module.css');
$module = JModuleHelper::getModule('mod_jcefilebrowser');
$width = 800;
$height = 600;
$filter = '';
if ($module) {
    $params = new JParameter($module->params);
    $width = $params->get('width', 800);
    $height = $params->get('height', 600);
    $filter = $params->get('filter', '');
}
$float = $language->isRTL() ? 'right' : 'left';
 /**
  * Overridden constructor
  * @access  protected
  */
 function __construct()
 {
     parent::__construct();
 }
示例#15
0
 public function authorize($task)
 {
     wfimport('admin.models.model');
     // map updates/blank/cpanel task to manage
     if (empty($task) || $task == 'cpanel' || $task == 'updates') {
         $task = 'manage';
     }
     if (WFModel::authorize($task) === false) {
         $this->setRedirect('index.php', WFText::_('ALERTNOTAUTH'), 'error');
         return false;
     }
     return true;
 }
示例#16
0
 /**
  * Pass in a WFModelEntity object with a name filled out.
  *
  * @param object WFModelEntity An WFModelEntity with a name.
  * @throws object WFModelEntity
  */
 function buildEntityModel($entity)
 {
     if (!$entity instanceof WFModelEntity) {
         throw new WFException("WFModelEntity required.");
     }
     $name = $entity->valueForKey('name');
     if (isset($this->builtEntities[$name])) {
         return $this->builtEntities[$name];
     }
     // build a WFModelEntity structure from the Propel metadata....
     $tableMap = $this->getEntityMetadata($name);
     // set up properties
     foreach ($tableMap->getColumns() as $column) {
         $property = new WFModelEntityProperty();
         $propertyName = $column->getPhpName();
         $propertyName[0] = strtolower($propertyName[0]);
         $property->setValueForKey($propertyName, 'name');
         $property->setValueForKey($column->getDefaultValue(), 'defaultValue');
         // BOOLEAN|TINYINT|SMALLINT|INTEGER|BIGINT|DOUBLE|FLOAT|REAL|DECIMAL|CHAR|{VARCHAR}|LONGVARCHAR|DATE|TIME|TIMESTAMP|BLOB|CLOB
         switch (strtoupper($column->getType())) {
             case 'TINYINT':
             case 'SMALLINT':
             case 'INTEGER':
             case 'BIGINT':
             case 'DOUBLE':
             case 'NUMERIC':
             case 'FLOAT':
             case 'REAL':
             case 'DECIMAL':
                 $type = WFModelEntityProperty::TYPE_NUMBER;
                 break;
             case 'TIMESTAMP':
             case 'DATETIME':
             case 'DATE':
                 $type = WFModelEntityProperty::TYPE_DATETIME;
                 break;
             case 'TEXT':
             case 'LONGVARCHAR':
                 $type = WFModelEntityProperty::TYPE_TEXT;
                 break;
             case 'BOOLEAN':
                 $type = WFModelEntityProperty::TYPE_BOOLEAN;
                 break;
             case 'CHAR':
             case 'VARCHAR':
             case 'STRING':
                 $type = WFModelEntityProperty::TYPE_STRING;
                 break;
             default:
                 print "WARNING: Unknown property type for column " . $property->valueForKey('name') . ": " . $column->getType() . "\n";
                 $type = WFModelEntityProperty::TYPE_STRING;
                 break;
         }
         if (!$entity->valueForKey('descriptiveColumnName') && $type === WFModelEntityProperty::TYPE_STRING) {
             $entity->setValueForKey($property->valueForKey('name'), 'descriptiveColumnName');
         }
         if (!$entity->valueForKey('primaryKeyProperty') && $column->isPrimaryKey()) {
             $entity->setValueForKey($property->valueForKey('name'), 'primaryKeyProperty');
         }
         $property->setValueForKey($type, 'type');
         $entity->addProperty($property);
     }
     if (!$entity->valueForKey('descriptiveColumnName')) {
         $entity->setValueForKey($entity->valueForKey('primaryKeyProperty'), 'descriptiveColumnName');
     }
     // set up relationships
     $tableMap->getRelations();
     // populate databaseMap with related columns
     foreach ($tableMap->getColumns() as $column) {
         if (!$column->isForeignKey()) {
             continue;
         }
         //print "Processing {$tableMap->getPhpName()}.{$column->getPhpName()}\n";
         // get related entity
         $relatedEntityName = $column->getRelatedTable()->getPhpName();
         $relatedEntityTableMap = $this->getEntityMetadata($relatedEntityName);
         $relatedEntity = WFModel::sharedModel()->getEntity($relatedEntityTableMap->getPhpName());
         if (!$relatedEntity) {
             //print "Building related WFModel entity {$relatedEntityTableMap->getPhpName()}\n";
             $relatedEntity = WFModel::sharedModel()->buildEntity($relatedEntityTableMap->getPhpName());
         }
         // configure relationship
         $relName = $relatedEntity->valueForKey('name');
         if (!$entity->getRelationship($relName)) {
             // create relationship from this table to the other one
             $rel = new WFModelEntityRelationship();
             $rel->setToOne(true);
             // if we are the fk column, it must be to-one (unless it's many-to-many)
             $rel->setValueForKey($relName, 'name');
             // singular
             $rel->setValueForKey($column->isNotNull(), 'required');
             $entity->addRelationship($rel);
         }
         // create relationship in the other direction
         $invRelName = $tableMap->getPhpName();
         // make plural as needed -
         if (!$relatedEntity->getRelationship($invRelName)) {
             $invRel = new WFModelEntityRelationship();
             // configure relationship
             $inverseRelationshipIsToOne = false;
             // is this an "extension" table? TRUE if the relationship is on our PK; this makes the INVERSE relationship have an EXT relationship to this table
             if ($column->isPrimaryKey()) {
                 $inverseRelationshipIsToOne = true;
                 $invRel->setValueForKey(true, 'isExtension');
             }
             $invRel->setToOne($inverseRelationshipIsToOne);
             $invRel->setValueForKey($invRelName, 'name');
             $relatedEntity->addRelationship($invRel);
         }
     }
     $this->builtEntities[$entity->valueForKey('name')] = $entity;
 }