public function handle($params)
 {
     $uitk = Dataface_ModuleTool::getInstance()->loadModule('modules_uitk');
     $uitk->registerPaths();
     Dataface_JavascriptTool::getInstance()->import('swete/actions/import_translations.js');
     df_display(array(), 'swete/actions/import_translations.html');
 }
 /**
  * Defines how a geopicker widget should be built.
  *
  * @param Dataface_Record $record The Dataface_Record that is being edited.
  * @param array &$field The field configuration data structure that the widget is being generated for.
  * @param HTML_QuickForm The form to which the field is to be added.
  * @param string $formFieldName The name of the field in the form.
  * @param boolean $new Whether this widget is being built for a new record form.
  * @return HTML_QuickForm_element The element that can be added to a form.
  *
  */
 function &buildWidget($record, &$field, $form, $formFieldName, $new = false)
 {
     $factory = Dataface_FormTool::factory();
     $mt = Dataface_ModuleTool::getInstance();
     $mod = $mt->loadModule('modules_geopicker');
     $widget =& $field['widget'];
     $atts = array();
     if (!@$atts['class']) {
         $atts['class'] = '';
     }
     $atts['class'] .= ' xf-geopicker';
     $atts['df:cloneable'] = 1;
     $perms = $record->getPermissions(array('field' => $field['name']));
     $noEdit = ($new and !@$perms['new']) or !$new and !@$perms['edit'];
     if ($noEdit) {
         $atts['data-geopicker-read-only'] = "1";
     }
     $mod->registerPaths();
     // Add our javascript
     Dataface_JavascriptTool::getInstance()->import('xataface/modules/geopicker/widgets/geopicker.js');
     $el = $factory->addElement('text', $formFieldName, $widget['label'], $atts);
     if (PEAR::isError($el)) {
         throw new Exception($el->getMessage(), $el->getCode());
     }
     return $el;
 }
Example #3
0
 function handle($params)
 {
     import('Dataface/SearchForm.php');
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $new = true;
     $form = new Dataface_SearchForm($query['-table'], $app->db(), $query);
     $res = $form->_build();
     if (PEAR::isError($res)) {
         trigger_error($res->toString() . Dataface_Error::printStackTrace(), E_USER_ERROR);
     }
     /*
      *
      * We need to add the current GET parameter flags (the GET vars starting with '-') so
      * that the controller knows to pass control to this method again upon form submission.
      *
      */
     $form->setDefaults(array('-action' => $query['-action']));
     if ($form->validate()) {
         $res = $form->process(array(&$form, 'performFind'));
     }
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->import('find.js');
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     $context = array('form' => &$out);
     df_display($context, 'Dataface_Find_View.html', true);
 }
Example #4
0
 function crawlPath($root, $path = null)
 {
     $js = Dataface_JavascriptTool::getInstance();
     if (isset($path)) {
         $dirpath = $root . DIRECTORY_SEPARATOR . $path;
         $docpath = $path . DIRECTORY_SEPARATOR . '__doc__.js';
         $fullpath = $root . DIRECTORY_SEPARATOR . $docpath;
     } else {
         $dirpath = $root;
         $docpath = '__doc__.js';
         $fullpath = $root . DIRECTORY_SEPARATOR . $docpath;
     }
     if (!is_readable($dirpath)) {
         return;
     }
     if (is_readable($fullpath)) {
         $js->import($docpath);
     }
     $files = scandir($dirpath);
     foreach ($files as $f) {
         if (strpos($f, '.') === 0) {
             continue;
         }
         $abspath = $dirpath . DIRECTORY_SEPARATOR . $f;
         if (is_dir($abspath)) {
             if (isset($path)) {
                 $this->crawlPath($root, $path . DIRECTORY_SEPARATOR . $f);
             } else {
                 $this->crawlPath($root, $f);
             }
         }
     }
 }
 function handle(&$params)
 {
     try {
         $app = Dataface_Application::getInstance();
         $query =& $app->getQuery();
         $jt = Dataface_JavascriptTool::getInstance();
         $jt->import('swete/ui/filter_translations.js');
         $app->addHeadContent('<link rel="stylesheet" type="text/css" href="css/swete/actions/review_translations.css"/>');
         if (!@$query['-recordid']) {
             throw new Exception("No record id was specified");
         }
         $record = df_get_record_by_id($query['-recordid']);
         $job = new SweteJob($record);
         $tm = XFTranslationMemory::loadTranslationMemoryFor($record, $record->val('source_language'), $record->val('destination_language'));
         $translations = $job->getTranslations();
         $template = 'swete/actions/review_translations.html';
         if (@$query['-isDialog']) {
             $template = 'swete/actions/review_translations_dlg.html';
         }
         df_display(array('job' => $job, 'translations' => $translations), $template);
     } catch (Exception $e) {
         if ($e->getCode() == E_USER_ERROR) {
             echo $e->getMessage();
         } else {
             throw $e;
         }
     }
 }
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->import('xataface/view/tests/test_MasterDetailView.js');
     df_display(array(), 'xataface/tests/test_MasterDetailView.html');
 }
Example #7
0
 /**
  * Returns the textarea element in HTML
  * 
  * @since     1.0
  * @access    public
  * @return    string
  */
 function toHtml()
 {
     $out = '';
     if (!defined('HTML_QuickForm_lookup_files_loaded')) {
         define('HTML_QuickForm_lookup_files_loaded', 1);
         $jt = Dataface_JavascriptTool::getInstance();
         $jt->import('xataface/widgets/lookup.js');
     }
     $properties = $this->getProperties();
     if ($this->_flagFrozen) {
         $properties['frozen'] = 1;
     }
     if (!isset($properties['callback'])) {
         $properties['callback'] = 'function(out){}';
     }
     ob_start();
     $oldFrozen = $this->_flagFrozen;
     $this->_flagFrozen = 0;
     $this->updateAttributes(array('data-xf-lookup-options' => json_encode($properties)));
     echo parent::toHtml();
     $this->_flagFrozen = $oldFrozen;
     $out .= ob_get_contents();
     ob_end_clean();
     $selector = null;
     if ($this->getName()) {
         $selector = "input[name='" . $this->getName() . "']";
     } else {
         $selector = '.xf-lookup-' . $this->index_prefix . '-' . $this->index;
     }
     return '<span style="white-space:nowrap">' . $out . '</span>';
 }
Example #8
0
 public function block__after_global_footer()
 {
     $js = Dataface_JavascriptTool::getInstance();
     $used = false;
     if ($js->getScripts()) {
         echo $js->getHtml();
     }
     return $used;
 }
Example #9
0
 function handle($params)
 {
     $js = Dataface_JavascriptTool::getInstance();
     $js->import('tests/doctest.js');
     $js->setMinify(false);
     $js->setUseCache(false);
     df_register_skin('xatajax', XATAJAX_PATH . DIRECTORY_SEPARATOR . 'templates');
     df_display(array(), 'tests/doctest.html');
 }
Example #10
0
 public function toHtml()
 {
     \Dataface_JavascriptTool::getInstance()->import('xataface/components/Portlet.js');
     ob_start();
     df_display(array('portlet' => $this), 'xataface/components/Portlet.html');
     $contents = ob_get_contents();
     ob_end_clean();
     return $contents;
 }
 /**
  * Defines how a depselect widget should be built.
  *
  * @param Dataface_Record $record The Dataface_Record that is being edited.
  * @param array &$field The field configuration data structure that the widget is being generated for.
  * @param HTML_QuickForm The form to which the field is to be added.
  * @param string $formFieldName The name of the field in the form.
  * @param boolean $new Whether this widget is being built for a new record form.
  * @return HTML_QuickForm_element The element that can be added to a form.
  *
  */
 function &buildWidget(&$record, &$field, &$form, $formFieldName, $new = false)
 {
     $factory = Dataface_FormTool::factory();
     $mt = Dataface_ModuleTool::getInstance();
     $mod = $mt->loadModule('modules_depselect');
     //$atts = $el->getAttributes();
     $widget =& $field['widget'];
     $atts = array();
     if (!@$atts['class']) {
         $atts['class'] = '';
     }
     $atts['class'] .= ' xf-depselect';
     if (!@$atts['data-xf-table']) {
         $atts['data-xf-table'] = $field['tablename'];
     }
     $targetTable = Dataface_Table::loadTable($field['widget']['table']);
     if (PEAR::isError($targetTable)) {
         error_log("Your field {$formFieldName} is missing the widget:table directive or the table does not exist.");
         throw new Exception("Your field {$formFieldName} is missing the widget:table directive or the table does not exist.");
     }
     $targetPerms = $targetTable->getPermissions();
     $atts['data-xf-depselect-options-table'] = $field['widget']['table'];
     if (@$targetPerms['new']) {
         $atts['data-xf-depselect-perms-new'] = 1;
     }
     $atts['df:cloneable'] = 1;
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->addPath(dirname(__FILE__) . '/js', $mod->getBaseURL() . '/js');
     $ct = Dataface_CSSTool::getInstance();
     $ct->addPath(dirname(__FILE__) . '/css', $mod->getBaseURL() . '/css');
     // Add our javascript
     $jt->import('xataface/widgets/depselect.js');
     $filters = array();
     if (@$field['widget']['filters'] and is_array($field['widget']['filters'])) {
         foreach ($field['widget']['filters'] as $key => $val) {
             $filters[] = urlencode($key) . '=' . urlencode($val);
         }
     }
     $atts['data-xf-depselect-filters'] = implode('&', $filters);
     if (@$field['widget']['nomatch']) {
         $atts['data-xf-depselect-nomatch'] = $field['widget']['nomatch'];
     }
     if (@$field['widget']['dialogSize']) {
         $atts['data-xf-depselect-dialogSize'] = $field['widget']['dialogSize'];
     }
     if (@$field['widget']['dialogMargin']) {
         $atts['data-xf-depselect-dialogMargin'] = $field['widget']['dialogMargin'];
     }
     //$el->setAttributes($atts);
     $el = $factory->addElement('depselect', $formFieldName, $widget['label'], $atts);
     if (PEAR::isError($el)) {
         throw new Exception($el->getMessage(), $el->getCode());
     }
     return $el;
 }
Example #12
0
 function block__before_result_list_content()
 {
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     $builder = new Dataface_QueryBuilder($query['-table'], $query);
     $sql = 'select sum(num_words) ' . $builder->_from() . $builder->_where();
     $res = df_q($sql);
     $row = mysql_fetch_row($res);
     @mysql_free_result($res);
     $app->addHeadContent('<style type="text/css">#total-words-found {float:right;width: 200px;}</style>');
     echo '<div id="total-words-found">Total Words: ' . $row[0] . '</div>';
     Dataface_JavascriptTool::getInstance()->import('swete/actions/batch_google_translate.js');
 }
Example #13
0
 function handleGet_noSettingsId($params)
 {
     $app = Dataface_Application::getInstance();
     $sites_to_import = array();
     $sites = df_get_records_array('websites', array());
     foreach ($sites as $site) {
         if ($site->checkPermission('import webpages')) {
             $sites_to_import[] = $site;
         }
     }
     Dataface_JavascriptTool::getInstance()->import('swete/actions/import_webpages/no_settings_id.js');
     df_display(array('sites_to_import' => $sites_to_import), 'swete/actions/import_webpages/no_settings_id.html');
 }
Example #14
0
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->import('forgot_password.js');
     try {
         if (isset($query['--uuid'])) {
             // A uuid was supplied,
             $res = $this->reset_password_with_uuid($query['--uuid']);
             if ($res) {
                 df_display(array(), 'xataface/forgot_password/password_has_been_reset.html');
                 exit;
             } else {
                 throw new Exception(df_translate('actions.forgot_password.failed_reset_for_uuid', "Failed to reset password for uuid") . ' ' . $query['--uuid']);
             }
         } else {
             if (isset($query['--email'])) {
                 $this->send_reset_email_for_email($query['--email']);
                 if (@$query['--format'] == 'json') {
                     $this->response(array('code' => 200, 'message' => df_translate('actions.forgot_password.email_sent_to_email', 'An email has been sent to the provided email address with instructions for resetting your password.')));
                     exit;
                 } else {
                     df_display(array(), 'xataface/forgot_password/sent_email.html');
                     exit;
                 }
             } else {
                 if (isset($query['--username'])) {
                     $this->send_reset_email_for_username($query['--username']);
                     if (@$query['--format'] == 'json') {
                         $this->response(array('code' => 200, 'message' => df_translate('actions.forgot_password.email_sent_to_email_for_username', 'An email has been sent to the email on file for this user account with instructions for resetting the password.')));
                         exit;
                     } else {
                         df_display(array(), 'xataface/forgot_password/sent_email.html');
                         exit;
                     }
                 } else {
                     df_display(array(), 'xataface/forgot_password/form.html');
                     exit;
                 }
             }
         }
     } catch (Exception $ex) {
         if (@$query['--format'] == 'json') {
             $this->response(array('code' => $ex->getCode(), 'message' => $ex->getMessage()));
             exit;
         } else {
             df_display(array('error' => $ex->getMessage()), 'xataface/forgot_password/form.html');
         }
     }
 }
Example #15
0
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     $website = df_get_record('websites', array('website_id' => '=' . $query['website_id']));
     if (!$website) {
         throw new Exception("Website could not be found.");
     }
     if (!$website->checkPermission('capture strings')) {
         return Dataface_Error::permissionDenied("You don't have permission to perform this action.");
     }
     Dataface_JavascriptTool::getInstance()->import('swete/actions/swete_tool_bar.js');
     import('inc/SweteSite.class.php');
     df_display(array('website' => $website, 'websiteWrapper' => new SweteSite($website)), 'swete/actions/toolbar_wrapper.html');
 }
Example #16
0
 public function __construct()
 {
     $app = Dataface_Application::getInstance();
     $s = DIRECTORY_SEPARATOR;
     if (isset($app->version) and $app->version >= 2) {
         $app->registerEventListener('SkinTool.ready', array($this, 'registerSkin'), true);
     } else {
         df_register_skin('g2', dirname(__FILE__) . $s . 'templates');
     }
     $app->registerEventListener('filterTemplateContext', array($this, 'filterTemplateContext'));
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->ignore('jquery.packed.js');
     $jt->ignore('jquery-ui.min.js');
     $jt->ignore('xatajax.core.js');
     $jt->ignore('xatajax.util.js');
     $jt->ignore('xataface/lang.js');
     $jt->ignoreCss('jquery-ui/jquery-ui.css');
     $app->addHeadContent('<script src="' . htmlspecialchars(DATAFACE_URL . '/js/xataface/lang.js') . '"></script>');
     $app->addHeadContent('<script src="' . htmlspecialchars(DATAFACE_URL . '/modules/XataJax/js/jquery.packed.js') . '"></script>');
     $app->addHeadContent('<script src="' . htmlspecialchars(DATAFACE_URL . '/modules/XataJax/js/jquery-ui.min.js') . '"></script>');
     $app->addHeadContent('<script src="' . htmlspecialchars(DATAFACE_URL . '/modules/XataJax/js/xatajax.core.js') . '"></script>');
     $app->addHeadContent('<script src="' . htmlspecialchars(DATAFACE_URL . '/modules/XataJax/js/xatajax.util.js') . '"></script>');
     $app->addHeadContent('<link rel="stylesheet" type="text/css" href="' . htmlspecialchars(DATAFACE_URL . '/modules/XataJax/css/jquery-ui/jquery-ui.css') . '"/>');
     $app->addHeadContent('<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($this->getBaseURL() . '/css/xataface-global.css') . '"/>');
     $jt->addPath(dirname(__FILE__) . $s . 'js', $this->getBaseURL() . '/js');
     $ct = Dataface_CSSTool::getInstance();
     $ct->addPath(dirname(__FILE__) . $s . 'css', $this->getBaseURL() . '/css');
     $jt->import('xataface/modules/g2/global.js');
     $app->addJSStrings(array('themes.g2.VIEW_SEARCH_RESULTS' => df_translate('themes.g2.VIEW_SEARCH_RESULTS', 'View Search Results'), 'themes.g2.SEARCH_RESULTS' => df_translate('themes.g2.SEARCH_RESULTS', 'Search Results')));
     // Let's create the actions for our tables.
     $app = Dataface_Application::getInstance();
     $order = -1000;
     $prefix = 'top_left_menu_actions_';
     $at = Dataface_ActionTool::getInstance();
     foreach ($app->_conf['_tables'] as $k => $v) {
         $nav = $app->getNavItem($k, $v);
         if ($nav) {
             $action = array('name' => $prefix . $k, 'label' => $nav['label'], 'description' => @$nav['description'], 'selected' => @$nav['selected'], 'url' => @$nav['href'], 'category' => 'top_left_menu_bar', 'order' => $order++);
             if (@$nav['permission']) {
                 $action['permission'] = $nav['permission'];
             }
             if (@$nav['condition']) {
                 $action['condition'] = $nav['condition'];
             }
             $at->addAction($prefix . $k, $action);
         }
     }
 }
 public function Dataface_Record__htmlValue($event)
 {
     $fieldname = $event->fieldname;
     $record = $event->record;
     $field =& $record->table()->getField($fieldname);
     if ($field['widget']['type'] === 'geopicker') {
         $this->registerPaths();
         Dataface_JavascriptTool::getInstance()->import('xataface/modules/geopicker/widgets/geopicker.js');
         $val = $record->val($fieldname);
         if (!trim($val)) {
             $event->out = '';
         } else {
             $event->out = '<input type="hidden" value="' . df_escape($val) . '" class="xf-geopicker" data-geopicker-read-only="1"/>';
             //out geopicker data in a hidden file (js code will substitute the textbox with the map)
         }
     }
 }
Example #18
0
 function handle($params)
 {
     session_write_close();
     $app = Dataface_Application::getInstance();
     $expires = 60 * 60 * 72;
     try {
         $query = $app->getQuery();
         $script = @$query['--script'];
         if (!$script) {
             throw new Exception("Script could not be found", 404);
         }
         $scripts = explode(',', $script);
         $jt = Dataface_JavascriptTool::getInstance();
         $jt->clearScripts();
         $app->fireEvent('beforeLoadScript');
         foreach ($scripts as $script) {
             $script = trim($script);
             //echo '['.$script.']';exit;
             $script = $this->sanitizePath($script);
             $jt->import($script);
         }
         header('Connection:close');
         $conf = Dataface_Application::getInstance()->_conf;
         $conf = @$conf['Dataface_JavascriptTool'];
         if (!$conf) {
             $conf = array();
         }
         if (!@$conf['debug']) {
             header("Pragma: public", true);
             header("Cache-Control:max-age=" . $expires . ', public, s-maxage=' . $expires, true);
             header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true);
         }
         header('Content-type: text/javascript; charset="' . $app->_conf['oe'] . '"');
         $out = $jt->getContents();
         header('Content-Length: ' . strlen($out));
         echo $out;
         flush();
     } catch (Exception $ex) {
         header('Content-type: text/javascript; charset="' . $app->_conf['oe'] . '"');
         $out = 'console.log(' . json_encode($ex->getMessage()) . ');';
         header('Content-Length: ' . strlen($out));
         echo $out;
         flush();
     }
 }
 function handle($params)
 {
     $js = Dataface_JavascriptTool::getInstance();
     $js->import('xatacard/layout/tests/RecordSetTest.js');
     $js->setMinify(false);
     $js->setUseCache(false);
     df_register_skin('xatajax', XATAJAX_PATH . DIRECTORY_SEPARATOR . 'templates');
     try {
         df_display(array(), 'tests/xatacard/layout/RecordSet/RecordSetTest.html');
     } catch (Exception $ex) {
         //echo "here";exit;
         while ($ex) {
             echo '<h3>' . $ex->getMessage() . '</h3>';
             echo nl2br(df_escape($ex->getTraceAsString()));
             $ex = $ex->getPrevious();
         }
     }
 }
Example #20
0
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $related_record = df_get_record_by_id($query['-related-record-id']);
     if (!$related_record || PEAR::isError($related_record)) {
         $this->out_404();
     }
     $app->_conf['orig_permissions'] = $related_record->_record->getPermissions();
     Dataface_PermissionsTool::addContextMask($related_record);
     $perms = $related_record->getPermissions();
     //print_r($perms);exit;
     if (!@$perms['view']) {
         return Dataface_Error::permissionDenied('You don\'t have permission to view this record.');
     }
     $query['-relationship'] = $related_record->_relationship->getName();
     Dataface_JavascriptTool::getInstance()->import('xataface/actions/view_related_record.js');
     df_display(array('related_record' => $related_record), 'xataface/actions/view_related_record.html');
 }
Example #21
0
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $auth = Dataface_AuthenticationTool::getInstance();
     $user = $auth->getLoggedInUser();
     $username = $auth->getLoggedInUsername();
     if (!$user or !$username) {
         return Dataface_Error::permissionDenied('You must be logged in to change your password');
     }
     if ($_POST) {
         try {
             if (!@$_POST['--password1'] || !@$_POST['--password2']) {
                 throw new Exception("Please enter your new password in both fields provided.");
             }
             if (!@$_POST['--current-password']) {
                 throw new Exception("Please enter your current password in the field provided.");
             }
             $_REQUEST['UserName'] = $username;
             $_REQUEST['Password'] = $_POST['--current-password'];
             if (!$auth->checkCredentials()) {
                 throw new Exception("The password you entered is incorrect.  Please try again.");
             }
             if (strcmp($_POST['--password1'], $_POST['--password2']) !== 0) {
                 throw new Exception("Your new passwords don't match.  Please ensure that you retype your new password correctly.");
             }
             $res = $auth->setPassword($_POST['--password1']);
             $this->out(array('code' => 200, 'message' => 'Your password has been successfully changed'));
             exit;
         } catch (Exception $ex) {
             $this->out(array('code' => $ex->getCode(), 'message' => $ex->getMessage()));
             exit;
         }
     } else {
         $jt = Dataface_JavascriptTool::getInstance();
         $jt->import('change_password.js');
         df_display(array(), 'change_password.html');
     }
 }
Example #22
0
 function block__custom_javascripts()
 {
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->import('swete/actions/add_selected_webpages_to_job.js');
     $jt->import('swete/actions/approve_pages.js');
 }
Example #23
0
 function handle($params)
 {
     Dataface_JavascriptTool::getInstance()->import('xataface/bootstrap.js');
     df_display(array(), 'xataface/tests/test_Bootstrap.html');
 }
Example #24
0
 function &buildWidget(&$record, &$field, &$form, $formFieldName, $new = false)
 {
     $table =& $record->_table;
     $widget =& $field['widget'];
     if (!@$widget['separator']) {
         $widget['separator'] = '<br />';
     }
     $factory =& Dataface_FormTool::factory();
     if (isset($field['repeat']) and $field['repeat'] and isset($field['vocabulary']) and $field['vocabulary'] or isset($field['transient']) and isset($field['relationship'])) {
         $boxes = array();
         $options = array();
         if (@$field['vocabulary']) {
             $options =& Dataface_FormTool::getVocabulary($record, $field);
             $options__classes = Dataface_FormTool::getVocabularyClasses($record, $field);
         } else {
             if (isset($field['relationship'])) {
                 $relationship =& $record->_table->getRelationship($field['relationship']);
                 $options = $relationship->getAddableValues($record);
                 $options__classes = array();
                 // Now let's add the ability to add an option that isn't already there
                 // but only if the user has permission
                 if (!@$widget['suffix']) {
                     $widget['suffix'] = '';
                 }
                 $dtable =& Dataface_Table::loadTable($relationship->getDomainTable());
                 if (!PEAR::isError($dtable) and $record->checkPermission('add new related record', array('relationship' => $relationship->getName()))) {
                     import('Dataface/JavascriptTool.php');
                     $jt = Dataface_JavascriptTool::getInstance();
                     $jt->import('xataface/widgets/checkbox.js');
                     //	$suffix =  '<script type="text/javascript" src="'.DATAFACE_URL.'/js/jquery-ui-1.7.2.custom.min.js"></script>';
                     //$suffix .= '<script type="text/javascript" src="'.DATAFACE_URL.'/js/RecordDialog/RecordDialog.js"></script>';
                     $suffix = '<a 
                                     class="xf-checkbox-widget-other-link"
                                     href="#" 
                                     onclick="return false" 
                                     id="' . df_escape($field['name']) . '-other"
                                     data-relationship-name="' . df_escape($relationship->getName()) . '"
                                     data-table-name="' . df_escape($dtable->tablename) . '"
                                     data-field-name="' . df_escape($field['name']) . '"
                                     data-keys="' . df_escape(json_encode(array_keys($dtable->keys()))) . '"
                                 >Other..</a>';
                     $widget['suffix'] = $suffix;
                 }
             }
         }
         if ($record and $record->val($field['name'])) {
             $vals = $record->val($field['name']);
             if (is_array($vals)) {
                 foreach ($vals as $thisval) {
                     if (!isset($options[$thisval])) {
                         $options[$thisval] = $thisval;
                     }
                 }
             }
         }
         $dummyForm = new HTML_QuickForm();
         foreach ($options as $opt_val => $opt_text) {
             if ($opt_val === '') {
                 continue;
             }
             $boxes[] =& $dummyForm->createElement('checkbox', $opt_val, null, $opt_text, array('class' => 'checkbox-of-' . $field['name'] . ' ' . @$options__classes[$opt_val]));
             //$boxes[count($boxes)-1]->setValue($opt_val);
         }
         $el =& $factory->addGroup($boxes, $field['name'], $widget['label']);
     } else {
         $el =& $factory->addElement('advcheckbox', $formFieldName, $widget['label']);
         if ($field['vocabulary']) {
             $yes = '';
             $no = '';
             if ($table->isYesNoValuelist($field['vocabulary'], $yes, $no)) {
                 $el->setValues(array($no, $yes));
             }
         }
     }
     return $el;
 }
Example #25
0
 function section__livewebpages(&$record)
 {
     require_once 'inc/SweteLiveWebpagesPresentation.php';
     $jsTool = Dataface_JavascriptTool::getInstance();
     $jsTool->import('swete/tables/jobs/livewebpages.js');
     $job = new SweteJob($record);
     $content = '<table class="job-livewebpages listing resultList" data-job-id="' . $record->val('job_id') . '" >' . SweteLiveWebpagesPresentation::tableContent($job) . '</table>';
     return array('content' => $content, 'class' => 'main', 'label' => 'Live Webpages', 'order' => 1);
 }
Example #26
0
    function &buildWidget(&$record, &$field, &$form, $formFieldName, $new = false)
    {
        $table =& $record->_table;
        $widget =& $field['widget'];
        $factory = Dataface_FormTool::factory();
        $attributes = array('class' => $widget['class'], 'id' => $field['name']);
        if ($field['repeat']) {
            $attributes['multiple'] = true;
            $attributes['size'] = 5;
        }
        $options = $record->_table->getValuelist($field['vocabulary']);
        //Dataface_FormTool::getVocabulary($record, $field);
        if (!isset($options)) {
            $options = array();
        }
        $emptyOpt = array('' => df_translate('scripts.GLOBAL.FORMS.OPTION_PLEASE_SELECT', "Please Select..."));
        $opts = $emptyOpt;
        if ($record and $record->val($field['name'])) {
            if (!@$field['repeat'] and !isset($options[$record->strval($field['name'])])) {
                $opts[$record->strval($field['name'])] = $record->strval($field['name']);
            } else {
                if (@$field['repeat']) {
                    $vals = $record->val($field['name']);
                    if (is_array($vals)) {
                        foreach ($vals as $thisval) {
                            if (!isset($options[$thisval])) {
                                $opts[$thisval] = $thisval;
                            }
                        }
                    }
                }
            }
        }
        foreach ($options as $kopt => $opt) {
            $opts[$kopt] = $opt;
        }
        $el = $factory->addElement('select', $formFieldName, $widget['label'], $opts, $attributes);
        // Now to make it editable
        if (@$field['vocabulary']) {
            try {
                $rel =& Dataface_ValuelistTool::getInstance()->asRelationship($table, $field['vocabulary']);
                if ($rel and !PEAR::isError($rel)) {
                    if (!is_a($rel, 'Dataface_Relationship')) {
                        throw new Exception("The relationship object for the vocabulary " . $field['vocabulary'] . " could not be loaded.");
                    }
                    if (!$rel->getDomainTable()) {
                        throw new Exception("The relationship object for the vocabulary " . $field['vocabulary'] . " could not be loaded or the domain table could not be found");
                    }
                    $dtable = Dataface_Table::loadTable($rel->getDomainTable());
                    if ($dtable and !PEAR::isError($dtable)) {
                        $perms = $dtable->getPermissions();
                        if (@$perms['new']) {
                            $fields =& $rel->fields();
                            if (count($fields) > 1) {
                                $valfield = $fields[1];
                                $keyfield = $fields[0];
                            } else {
                                $valfield = $fields[0];
                                $keyfield = $fields[0];
                            }
                            if (strpos($valfield, '.') !== false) {
                                list($tmp, $valfield) = explode('.', $valfield);
                            }
                            if (strpos($keyfield, '.') !== false) {
                                list($tmp, $keyfield) = explode('.', $keyfield);
                            }
                            $jt = Dataface_JavascriptTool::getInstance();
                            $jt->import('RecordDialog/RecordDialog.js');
                            //$suffix =  '<script type="text/javascript" src="'.DATAFACE_URL.'/js/jquery-ui-1.7.2.custom.min.js"></script>';
                            //$suffix .= '<script type="text/javascript" src="'.DATAFACE_URL.'/js/RecordDialog/RecordDialog.js"></script>';
                            $suffix = '<a href="#" onclick="return false" id="' . df_escape($field['name']) . '-other">Other..</a>';
                            $suffix .= '<script>
							jQuery(document).ready(function($){
								$("#' . $field['name'] . '-other").each(function(){
									var tablename = "' . addslashes($dtable->tablename) . '";
									var valfld = ' . json_encode($valfield) . ';
									var keyfld = ' . json_encode($keyfield) . ';
									var fieldname = ' . json_encode($field['name']) . ';
									var btn = this;
									$(this).RecordDialog({
										table: tablename,
										callback: function(data){
											var key = data[keyfld];
											var val = data[valfld];
                                                                                        var $option = $(\'<option value="\'+key+\'">\'+val+\'</option>\');
                                                                                        
											$("#"+fieldname).append($option);
											$("#"+fieldname).val(key);
                                                                                        if ( !val || val === key ){
                                                                                            var q = {
                                                                                                "-action" : "field_vocab_value",
                                                                                                "-key" : key,
                                                                                                "-table" : ' . json_encode($field['tablename']) . ',
                                                                                                "-field" : ' . json_encode($field['name']) . '
                                                                                            };
                                                                                            $.get(DATAFACE_SITE_HREF, q, function(res){
                                                                                                if ( res && res.code === 200 ){
                                                                                                    $option.text(res.value);
                                                                                                }
                                                                                            });
                                                                                        }
											
										}
									});
								});
							});
							</script>
							';
                            $widget['suffix'] = $suffix;
                        }
                    }
                }
            } catch (Exception $ex) {
                error_log($ex->getMessage());
            }
        }
        //$el->setFieldDef($field);
        //return $el;
        return $el;
    }
Example #27
0
<?php

import('PHPUnit.php');
class ModelsTest extends PHPUnit_TestCase
{
    function __construct($name)
    {
        $this->PHPUnit_TestCase($name);
    }
}
$jt = Dataface_JavascriptTool::getInstance();
$jt->import('xataface/model/tests/ModelTest.js');
$jt->import('xataface/model/tests/ListModelTest.js');
$jt->import('xataface/model/tests/MasterDetailModelTest.js');
$jt->import('xataface/store/tests/DocumentTest.js');
$jt->import('xataface/store/tests/ResultSetTest.js');
$jt->import('xataface/store/tests/MasterDetailStoreTest.js');
$jt->import('xataface/form/tests/FormElementTest.js');
$jt->import('xataface/form/tests/FormTest.js');
$jt->import('xataface/tests/ClassLoaderTest.js');
Example #28
0
    function handle(&$params)
    {
        $app =& Dataface_Application::getInstance();
        $query =& $app->getQuery();
        $table =& Dataface_Table::loadTable($query['-table']);
        $records = df_get_selected_records($query);
        if (count($records) == 0) {
            unset($records);
            $q = $query;
            $q['-start'] = 0;
            $q['-limit'] = 9999;
            $records =& df_get_records_array($query['-table'], $q);
        }
        // Now we find out a few things, like whether we're doing a related record
        // list or the real list
        $fields = $this->getFieldsForRecord($records[0]);
        $field_options = array(0 => df_translate('actions.copy_replace.options.select_field_to_change', 'Select field to change...'));
        foreach ($fields as $field) {
            $field_options[$field['name']] = $field['widget']['label'];
        }
        $this->form = new HTML_QuickForm('copy_replace_form', 'POST');
        $form =& $this->form;
        $this->addFields($form, $fields);
        // Add the submit button and extra checkbox for copy
        $form->addElement('hidden', '-copy_replace:fields');
        $el =& $form->addElement('hidden', '-copy_replace:copy');
        if (@$query['--copy']) {
            $form->setDefaults(array('-copy_replace:copy' => 1));
            $message = df_translate('actions.copy_replace.copy_message', <<<END
\t\t\t\tThis form allows you to copy the selected records and update the 
\t\t\t\tvalues of particular fields in the copies.
END
);
            $title = df_translate('actions.copy_replace.copy_form_title', "Copy Records Form");
            $warning = df_translate('actions.copy_replace.copy_warning_message', <<<END
\t\t\t\tProceeding with this action will make copies of all selected records.
\t\t\t\tUse caution and care when using this form.
END
);
        } else {
            $message = df_translate('actions.copy_replace.update_message', <<<END
\t\t\t\tThis form allows you to perform batch updates on all of the selected
\t\t\t\trecords.  Use the form below to specify values to be placed in
\t\t\t\tany field.
END
);
            $warning = df_translate('actions.copy_replace.update_warning_message', <<<END
\t\t\t\tProceeding with this action will update ALL selected records.  You may not be able to undo these changes.  Use caution
\t\t\t\tand care when using this form.
END
);
            $title = df_translate('actions.copy_replace.update_form_title', "Find/Replace Form");
        }
        foreach ($query as $key => $val) {
            $res = $form->addElement('hidden', $key);
            $form->setDefaults(array($key => $val));
        }
        $form->addElement('hidden', '-copy_replace:submit');
        $form->setDefaults(array('-copy_replace:submit' => 1));
        $submit =& $form->addElement('submit', '-copy_replace:submit_btn', df_translate('actions.copy_replace.submit_label', 'Perform Update Now'));
        if (@$_POST['-copy_replace:submit'] and $form->validate()) {
            $res = $form->process(array(&$this, 'process'), true);
            if (!PEAR::isError($res)) {
                $q = array();
                foreach (array_keys($query) as $key) {
                    // Remove extra copy/replace keys before forwarding
                    if (strstr($key, '-copy_replace:') == $key or strstr($key, '-copy_replace_form:') == $key) {
                        $q[$key] = null;
                    }
                }
                if (isset($query['-from'])) {
                    $q['-action'] = $query['-from'];
                    unset($q['-from']);
                } else {
                    $q['-action'] = 'list';
                }
                $url = $app->url($q);
                $app->redirect($url . '&--msg=' . urlencode($this->message));
            }
        }
        $form->accept($this->renderer);
        $out = $this->renderer->toHtml();
        $jt = Dataface_JavascriptTool::getInstance();
        $jt->import('xataface/copy_replace.js');
        df_display(array('title' => $title, 'message' => $message, 'warning' => $warning, 'records' => $records, 'columns' => $this->getKeysForRecord($records[0]), 'form' => $out, 'context' => &$this, 'field_options' => $field_options), 'copy_replace.html');
        return;
    }
Example #29
0
 function beforeHandleRequest()
 {
     $app = Dataface_Application::getInstance();
     $app->addHeadContent('<link rel="stylesheet" type="text/css" href="' . htmlspecialchars(DATAFACE_SITE_URL . '/css/swete/global.css') . '"/>');
     $query =& $app->getQuery();
     $res = df_q("select language_code, language_label from languages");
     $langs = array();
     while ($row = mysql_fetch_row($res)) {
         $langs[$row[0]] = $row[1];
     }
     @mysql_free_result($res);
     $app->_conf['languages'] = $langs;
     $app->registerEventListener('tm.setTranslationStatus', array($this, 'handleTranslationStatusChanged'));
     Dataface_JavascriptTool::getInstance()->import('swete/global.js');
     if (@$app->_conf['using_default_action'] and $query['-table'] == 'dashboard') {
         $query['-action'] = 'dashboard';
     }
 }
Example #30
0
    function toHtml()
    {
        $context = array();
        $context['relatedList'] = $this;
        $app =& Dataface_Application::getInstance();
        $context['app'] =& $app;
        $query =& $app->getQuery();
        $context['query'] =& $query;
        if (isset($query['-related:sort'])) {
            $sortcols = explode(',', trim($query['-related:sort']));
            $sort_columns = array();
            foreach ($sortcols as $sortcol) {
                $sortcol = trim($sortcol);
                if (strlen($sortcol) === 0) {
                    continue;
                }
                $sortcol = explode(' ', $sortcol);
                if (count($sortcol) > 1) {
                    $sort_columns[$sortcol[0]] = strtolower($sortcol[1]);
                } else {
                    $sort_columns[$sortcol[0]] = 'asc';
                }
                break;
            }
            unset($sortcols);
            // this was just a temp array so we get rid of it here
        } else {
            $sort_columns = array();
        }
        $context['sort_columns'] =& $sort_columns;
        $sort_columns_arr = array();
        foreach ($sort_columns as $colkey => $colorder) {
            $sort_columns_arr[] = '`' . $colkey . '`' . $colorder;
        }
        if (count($sort_columns_arr) > 0) {
            $sort_columns_str = implode(', ', $sort_columns_arr);
        } else {
            $sort_columns_str = 0;
        }
        unset($query);
        $skinTool =& Dataface_SkinTool::getInstance();
        $context['skinTool'] =& $skinTool;
        $resultController =& $skinTool->getResultController();
        $context['resultController'] =& $resultController;
        $s =& $this->_table;
        $r =& $this->_relationship->_schema;
        $fkeys = $this->_relationship->getForeignKeyValues();
        $local_fkey_fields = array();
        foreach ($fkeys as $fk_table_name => $fk_table_cols) {
            foreach ($fk_table_cols as $k => $v) {
                if (is_string($v) and $v and $v[0] === '$') {
                    $local_fkey_fields[$k] = $v;
                }
            }
        }
        $default_order_column = $this->_relationship->getOrderColumn();
        //echo "Def order col = $default_order_column";
        ob_start();
        df_display(array('redirectUrl' => $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']), 'Dataface_MoveUpForm.html');
        $moveUpForm = ob_get_contents();
        ob_end_clean();
        $context['moveUpForm'] = $moveUpForm;
        $records =& $this->_record->getRelatedRecords($this->_relationship_name, true, $this->_start, $this->_limit, $this->_where);
        if (PEAR::isError($records)) {
            $records->addUserInfo("Error retrieving records from relationship " . $this->_relationship_name);
            return $records;
        }
        $context['records'] =& $records;
        //echo "<br/><b>Now Showing</b> ".($this->_start+1)." to ".(min($this->_start + $this->_limit, $this->_record->numRelatedRecords($this->_relationship_name)));
        $perms = $this->_record->getPermissions(array('relationship' => $this->_relationship_name));
        $context['perms'] = $perms;
        $context['record_editable'] = Dataface_PermissionsTool::edit($this->_record);
        $context['can_add_new_related_record'] = @$perms['add new related record'];
        $context['can_add_existing_related_record'] = @$perms['add existing related record'];
        if (!$this->hideActions and ($context['record_editable'] or @$perms['add new related record'] or @$perms['add existing related record'])) {
            $query = array('-action' => 'new_related_record');
            $link = Dataface_LinkTool::buildLink($query);
            $context['new_related_record_query'] = $query;
            $context['new_related_record_link'] = $link;
            $domainTable = $this->_relationship->getDomainTable();
            //$context['domainTable'] =& $domainTable;
            $importTablename = $domainTable;
            if (!PEAR::isError($domainTable)) {
                //This relationship is many-to-many so we can add existing records to it.
                $query2 = array('-action' => 'existing_related_record');
                $context['existing_related_record_query'] = $query2;
                $link2 = Dataface_LinkTool::buildLink($query2);
                $context['existing_related_record_link'] = $link2;
                $destTables = $this->_relationship->getDestinationTables();
                $context['destTables'] =& $destTables;
                $importTablename = $destTables[0]->tablename;
                $context['importTablename'] = $importTablename;
            }
            if (!PEAR::isError($importTablename)) {
                $importTable =& Dataface_Table::loadTable($importTablename);
                $context['importTable'] =& $importTable;
                $query3 = array('-action' => 'import');
                $context['import_related_records_query'] =& $query3;
                $link3 = Dataface_LinkTool::buildLink($query3);
                $context['import_related_records_link'] = $link3;
            }
        }
        $imgIcon = DATAFACE_URL . '/images/search_icon.gif';
        $searchSrc = DATAFACE_URL . '/js/Dataface/RelatedList/search.js';
        $relname = $this->_relationship_name;
        $context['relationship_label'] = $this->_relationship->getLabel();
        $context['relname'] = $relname;
        $context['relationship_name'] = $this->_relationship_name;
        $context['searchSrc'] = $searchSrc;
        $context['imgIcon'] = $imgIcon;
        if (!$this->hideActions) {
            $num_related_records = $this->_record->numRelatedRecords($this->_relationship_name, $this->_where);
            $now_showing_start = $this->_start + 1;
            $now_showing_finish = min($this->_start + $this->_limit, $this->_record->numRelatedRecords($this->_relationship_name, $this->_where));
            $stats_context = array('num_related_records' => $num_related_records, 'now_showing_start' => $now_showing_start, 'now_showing_finish' => $now_showing_finish, 'relationship_name' => $this->_relationship_name, 'limit_field' => $resultController->limitField('related:'), 'back_link' => $this->_backButtonHtml(), 'next_link' => $this->_forwardButtonHtml());
            import('Dataface/ActionTool.php');
            $at =& Dataface_ActionTool::getInstance();
            $actions = $at->getActions(array('category' => 'related_list_actions'));
            $context['related_list_actions'] = $actions;
            foreach ($stats_context as $k => $v) {
                $context[$k] = $v;
            }
        }
        import('Dataface/ActionTool.php');
        $at =& Dataface_ActionTool::getInstance();
        $selected_actions = $at->getActions(array('category' => 'selected_related_result_actions'));
        $context['selected_actions'] = $selected_actions;
        if ($this->_relationship->_schema['list']['type'] == 'treetable') {
            import('Dataface/TreeTable.php');
            $treetable = new Dataface_TreeTable($this->_record, $this->_relationship->getName());
            $context['treetable'] = $treetable->toHtml();
        } else {
            echo $moveUpForm;
            if (!$this->hideActions and $this->_where) {
                $filterQuery =& $app->getQuery();
                $context['filterQuery'] =& $filterQuery;
            }
            if (count($records) > 0) {
                ob_start();
                echo '
                        <table class="listing relatedList relatedList--' . $this->_tablename . ' relatedList--' . $this->_tablename . '--' . $this->_relationship_name . '" id="relatedList">
                        <thead>
                        <tr>';
                if (count($selected_actions) > 0) {
                    echo '<th>';
                    if (!$this->hideActions) {
                        echo '<input type="checkbox" onchange="toggleSelectedRows(this,\'relatedList\');">';
                    }
                    echo '</th>';
                }
                $cols = array_keys(current($records));
                $col_tables = array();
                $table_keys = array();
                $localFields = $this->_record->table()->fields();
                $usedColumns = array();
                foreach ($cols as $key) {
                    if ($key == $default_order_column) {
                        continue;
                    }
                    if (is_int($key)) {
                        continue;
                    }
                    if (isset($sort_columns[$key])) {
                        $class = 'sorted-column-' . $sort_columns[$key];
                        $query = array();
                        $qs_columns = $sort_columns;
                        unset($qs_columns[$key]);
                        $sort_query = $key . ' ' . ($sort_columns[$key] == 'desc' ? 'asc' : 'desc');
                        foreach ($qs_columns as $qcolkey => $qcolvalue) {
                            $sort_query .= ', ' . $qcolkey . ' ' . $qcolvalue;
                        }
                    } else {
                        $class = 'unsorted-column';
                        $sort_query = $key . ' asc';
                        foreach ($sort_columns as $scolkey => $scolvalue) {
                            $sort_query .= ', ' . $scolkey . ' ' . $scolvalue;
                        }
                    }
                    $sq = array('-related:sort' => $sort_query);
                    $link = Dataface_LinkTool::buildLink($sq);
                    $fullpath = $this->_relationship_name . '.' . $key;
                    $field =& $this->_relationship->getField($key);
                    if (isset($this->_relationship->_schema['visibility'][$key]) and $this->_relationship->_schema['visibility'][$key] == 'hidden') {
                        continue;
                    }
                    if ($field['visibility']['list'] != 'visible') {
                        continue;
                    }
                    if ($s->isBlob($fullpath) or $s->isPassword($fullpath)) {
                        continue;
                    }
                    if (isset($local_fkey_fields[$key]) and !isset($this->_relationship->_schema['visibility'][$key])) {
                        continue;
                    }
                    if (PEAR::isError($field)) {
                        $field->addUserInfo("Error getting field info for field {$key} in RelatedList::toHtml() ");
                        return $field;
                    }
                    $usedColumns[] = $key;
                    $label = $field['widget']['label'];
                    if (isset($field['column']) and @$field['column']['label']) {
                        $label = $field['column']['label'];
                    }
                    $legend = '';
                    if (@$field['column'] and @$field['column']['legend']) {
                        $legend = '<span class="column-legend">' . df_escape($field['column']['legend']) . '</span>';
                    }
                    if (!$this->noLinks) {
                        echo '<th><a href="' . df_escape($link) . '">' . df_escape($field['widget']['label']) . "</a> {$legend}</th>\n";
                    } else {
                        echo '<th>' . $field['widget']['label'] . '</th>';
                    }
                    if (!isset($col_tables[$key])) {
                        $col_tables[$key] = $field['tablename'];
                    }
                    if (!isset($table_keys[$col_tables[$key]])) {
                        $table_table =& Dataface_Table::loadTable($field['tablename']);
                        $table_keys[$col_tables[$key]] = array_keys($table_table->keys());
                        unset($table_table);
                    }
                    unset($field);
                }
                echo "</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody id=\"relatedList-body\">\n\t\t\t\t\t";
                $limit = min($this->_limit, $this->_record->numRelatedRecords($this->_relationship_name, $this->_where) - $this->_start);
                $relatedTable = $this->_relationship->getDomainTable();
                if (PEAR::isError($relatedTable)) {
                    $relatedTable = reset($r['selected_tables']);
                }
                $relatedTable = Dataface_Table::loadTable($relatedTable);
                $relatedKeys = array_keys($relatedTable->keys());
                foreach (array_keys($relatedKeys) as $i) {
                    $relatedKeys[$i] = $this->_relationship_name . "." . $relatedKeys[$i];
                }
                $fullpaths = array();
                $fields_index = array();
                foreach ($usedColumns as $key) {
                    $fullpaths[$key] = $this->_relationship_name . '.' . $key;
                    $fields_index[$key] =& $this->_relationship->getField($key);
                }
                $evenRow = false;
                for ($i = $this->_start; $i < $this->_start + $limit; $i++) {
                    $rowClass = $evenRow ? 'even' : 'odd';
                    $evenRow = !$evenRow;
                    if ($default_order_column and @$perms['reorder_related_records']) {
                        $style = 'cursor:move';
                        // A variable that will be used below in javascript to decide
                        // whether to make the table sortable or not
                        $sortable_js = 'true';
                    } else {
                        $style = '';
                        $sortable_js = 'false';
                    }
                    $context['sortable_js'] = $sortable_js;
                    unset($rrec);
                    $rrec = $this->_record->getRelatedRecord($this->_relationship_name, $i, $this->_where, $sort_columns_str);
                    //new Dataface_RelatedRecord($this->_record, $this->_relationship_name, $this->_record->getValues($fullpaths, $i, 0, $sort_columns_str));
                    $rrecid = $rrec->getId();
                    $rowPerms = $rrec->getPermissions();
                    if (!@$rowPerms['view']) {
                        continue;
                    }
                    echo "<tr class=\"listing {$rowClass}\" style=\"{$style}\" id=\"row_{$rrecid}\">";
                    if (count($selected_actions) > 0) {
                        echo '
						<td class="' . $rowClass . ' viewableColumn" nowrap>';
                        if (!$this->hideActions) {
                            echo '<input xf-record-id="' . df_escape($rrecid) . '" class="rowSelectorCheckbox" id="rowSelectorCheckbox:' . df_escape($rrecid) . '" type="checkbox">';
                        }
                        echo '</td>';
                    }
                    $link_queries = array();
                    foreach ($usedColumns as $key) {
                        if (is_int($key)) {
                            continue;
                        }
                        $fullpath = $fullpaths[$key];
                        unset($field);
                        $field =& $fields_index[$key];
                        //$s->getField($fullpath);
                        $srcRecord =& $rrec->toRecord($field['tablename']);
                        if (!@$app->_conf['legacy_compatibility_mode']) {
                            $link = $this->_record->getURL('-action=view_related_record&-related-record-id=' . urlencode($rrecid));
                        } else {
                            //$link = $srcRecord->getURL('-action=browse&-portal-context=' . urlencode($rrecid));
                            $link = $rrec->getURL('-action=browse', $field['tablename']);
                        }
                        $srcRecordId = $srcRecord->getId();
                        //$val = $this->_record->preview($fullpath, $i,255, $this->_where, $sort_columns_str);
                        if ($srcRecord->table()->isContainer($field['name']) or $srcRecord->table()->isBlob($field['name'])) {
                            $val = $rrec->htmlValue($key, array('class' => 'blob-preview'));
                            //$rrec->htmlValue($key);
                        } else {
                            $val = strip_tags($rrec->display($key));
                        }
                        $title = "";
                        if ($key == $default_order_column) {
                            unset($field);
                            unset($srcRecord);
                            continue;
                        } else {
                            if ($val != 'NO ACCESS') {
                                $accessClass = 'viewableColumn';
                            } else {
                                $accessClass = '';
                            }
                            $cellClass = 'resultListCell resultListCell--' . $key;
                            $cellClass .= ' ' . $srcRecord->table()->getType($key);
                            $renderVal = $this->renderCell($srcRecord, $field['Field']);
                            if (isset($renderVal)) {
                                $val = $renderVal;
                            }
                            if ($link and !@$field['noLinkFromListView'] and !$this->noLinks and $rrec->checkPermission('link', array('field' => $key))) {
                                $val = "<a href=\"" . df_escape($link) . "\" title=\"" . df_escape($title) . "\" data-xf-related-record-id=\"" . df_escape($srcRecordId) . "\" class=\"xf-related-record-link\">" . $val . "</a>";
                            }
                            echo "<td class=\"{$cellClass} {$rowClass} {$accessClass}\">{$val}</td>\n";
                            unset($srcRecord);
                        }
                    }
                    echo "</tr>\n";
                }
                echo "</tbody>\n\t\t\t\t\t</table>";
                $related_table_html = ob_get_contents();
                $context['related_table_html'] = $related_table_html;
                ob_end_clean();
                if (!$this->hideActions) {
                    ob_start();
                    echo '<form id="result_list_selected_items_form" method="post">';
                    $app =& Dataface_Application::getInstance();
                    $q =& $app->getQuery();
                    foreach ($q as $key => $val) {
                        if (strlen($key) > 1 and $key[0] == '-' and $key[1] == '-') {
                            continue;
                        }
                        echo '<input type="hidden" name="' . $key . '" value="' . df_escape($val) . '">';
                    }
                    echo '<input type="hidden" name="--selected-ids" id="--selected-ids">';
                    echo '<input type="hidden" name="-from" id="-from" value="' . $q['-action'] . '">';
                    echo '</form>';
                    $selected_actions_form = ob_get_contents();
                    $context['selected_actions_form'] = $selected_actions_form;
                    ob_end_clean();
                    // This bit of javascript goes through all of the columns and removes all columns that
                    // don't have any accessible information for this query.  (i.e. any columns for which
                    // each row's value is 'NO ACCESS' is removed
                    $prototype_url = DATAFACE_URL . '/js/scriptaculous/lib/prototype.js';
                    $context['prototype_url'] = $prototype_url;
                    $scriptaculous_url = DATAFACE_URL . '/js/scriptaculous/src/scriptaculous.js';
                    $context['scriptaculous_url'] = $scriptaculous_url;
                    $effects_url = DATAFACE_URL . '/js/scriptaculous/src/effects.js';
                    $context['effects_url'] = $effects_url;
                    $dragdrop_url = DATAFACE_URL . '/js/scriptaculous/src/dragdrop.js';
                    $context['dragdrop_url'] = $dragdrop_url;
                    $thisRecordID = $this->_record->getId();
                    $context['thisRecordID'] = $thisRecordID;
                }
            }
        }
        Dataface_JavascriptTool::getInstance()->import('xataface/actions/related_list.js');
        ob_start();
        $context['filters'] = $this->filters;
        df_display($context, 'xataface/RelatedList/list.html');
        $out = ob_get_contents();
        ob_end_clean();
        return $out;
    }