Beispiel #1
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query = $app->getQuery();
     $query['-skip'] = 0;
     $query['-limit'] = 999999999;
     $at = Dataface_ActionTool::getInstance();
     $emailAction = $at->getAction(array('name' => 'email'));
     if (!isset($emailAction) or !isset($emailAction['email_column'])) {
         return PEAR::raiseError("No email column specified");
     }
     $col = $emailAction['email_column'];
     $qb = new Dataface_QueryBuilder($query['-table'], $query);
     $sql = "select `" . $col . "` " . $qb->_from() . $qb->_secure($qb->_where());
     $res = mysql_query($sql, df_db());
     if (!$res) {
         trigger_error(mysql_error(df_db()), E_USER_ERROR);
     }
     $addresses = array();
     while ($row = mysql_fetch_row($res)) {
         $addresses[] = $row[0];
     }
     @mysql_free_result($res);
     header("Content-type: text/plain");
     echo implode(', ', $addresses);
     exit;
 }
Beispiel #2
0
 /**
  * We just want this to run before the left column is rendered.. We're not using it for output
  */
 public function block__before_left_column()
 {
     // Let's create the actions for our tables.
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     $order = -1000;
     $at = Dataface_ActionTool::getInstance();
     $table = Dataface_Table::loadTable($query['-table']);
     $search = $this->getCurrentSearch();
     if (@$query['-search']) {
         $search['-search'] = $query['-search'];
     }
     $showAll = array('name' => 'show_all_records', 'label' => df_translate('actions.show_all_records.label', 'All ' . $table->getLabel()), 'description' => df_translate('actions.show_all_records.description', 'Show all records in ' . $table->getLabel()), 'selected' => !$search and @$query['-mode'] == 'list', 'url' => DATAFACE_SITE_HREF . '?-table=' . htmlspecialchars($table->tablename), 'category' => 'table_quicklinks', 'order' => -1000);
     $at->addAction('show_all_records', $showAll);
     // We want to get the last search results
     /*
     $thisSearch = $search;
     if ( !$search ){
     	$thisSearch = @$_SESSION['xf_last_search_query'];
     	if ( $thisSearch ){
     		$thisSearch = @$thisSearch[$query['-table']];
     	}
     } else {
     	$_SESSION['xf_last_search_query'][$query['-table']] = $search;
     }
     
     if ( $thisSearch){
     	
     	$searchResults = array(
     		'name' => 'search_results',
     		'label' => 'Search Results',
     		'description' => 'Search results',
     		'selected' => $search,
     		'url' => $app->url($thisSearch),
     		'category' => 'table_quicklinks',
     		'order' => -999
     	);
     	$at->addAction('search_results', $searchResults);
     }
     */
 }
Beispiel #3
0
 /**
  * Returns a list of the relationships for this table as actions.
  * Relationships can carry any action attributes and indeed can be treated as actions themselves
  * for purposes of displaying menus of the various relationships primarily.
  */
 function getRelationshipsAsActions($params = array(), $relationshipName = null, $passthru = false)
 {
     $relationships =& $this->relationships();
     $rkeys = array_keys($relationships);
     if (isset($this->_cache['getRelationshipsAsActions'])) {
         $actions = $this->_cache['getRelationshipsAsActions'];
     } else {
         $actions = array();
         foreach ($rkeys as $key) {
             $srcTable =& $relationships[$key]->getSourceTable();
             $actions[$key] = array('name' => $key, 'id' => $key, 'label' => $key, 'url' => '{$this->url(\'-action=related_records_list&-relationship=' . $key . '\')}', 'selected_condition' => '$query[\'-relationship\'] == \'' . $key . '\'', 'condition' => '$record and $record->checkPermission("view related records", array("relationship"=>$key))', 'order' => 1, 'visible' => !$relationships[$key]->isParentRelationship() ? 1 : 0);
             if (isset($relationships[$key]->_schema['action'])) {
                 $actions[$key] = array_merge($actions[$key], $relationships[$key]->_schema['action']);
             }
             $actions[$key]['label'] = df_translate('tables.' . $srcTable->tablename . '.relationships.' . $key . '.label', @$actions[$key]['label']);
             $actions[$key]['description'] = df_translate('tables.' . $srcTable->tablename . '.relationships.' . $key . '.description', @$actions[$key]['description']);
             unset($srcTable);
         }
         $this->_cache['getRelationshipsAsActions'] = $actions;
     }
     import('Dataface/ActionTool.php');
     $actionsTool =& Dataface_ActionTool::getInstance();
     $out = $actionsTool->getActions($params, $actions);
     if (isset($relationshipName)) {
         if (isset($out[$relationshipName])) {
             return @$out[$relationshipName];
         } else {
             return $actionsTool->getAction($params, $actions[$relationshipName]);
         }
     }
     return $out;
 }
Beispiel #4
0
    function toHtml()
    {
        $app =& Dataface_Application::getInstance();
        $query =& $app->getQuery();
        if (isset($query['-sort'])) {
            $sortcols = explode(',', trim($query['-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();
        }
        // $sort_columns should now be of the form [ColumnName] -> [Direction]
        // where Direction is "asc" or "desc"
        if ($this->_resultSet->found() > 0) {
            if (@$app->prefs['use_old_resultlist_controller']) {
                ob_start();
                df_display(array(), 'Dataface_ResultListController.html');
                $controller = ob_get_contents();
                ob_end_clean();
            }
            ob_start();
            //echo '<div style="clear: both"/>';
            if (!defined('Dataface_ResultList_Javascript')) {
                define('Dataface_ResultList_Javascript', true);
                echo '<script language="javascript" type="text/javascript" src="' . DATAFACE_URL . '/js/Dataface/ResultList.js"></script>';
            }
            if (!@$app->prefs['hide_result_filters'] and count($this->_filterCols) > 0) {
                echo $this->getResultFilters();
            }
            unset($query);
            if (@$app->prefs['use_old_resultlist_controller']) {
                echo '<div class="resultlist-controller" id="resultlist-controller-top">';
                echo $controller;
                echo "</div>";
            }
            $canSelect = false;
            if (!@$app->prefs['disable_select_rows']) {
                $canSelect = Dataface_PermissionsTool::checkPermission('select_rows', Dataface_PermissionsTool::getPermissions($this->_table));
            }
            echo '<table  id="result_list" class="listing">
				<thead>
				<tr>';
            if ($canSelect) {
                echo '<th><input type="checkbox" onchange="toggleSelectedRows(this,\'result_list\');"></th>';
            }
            if (!@$app->prefs['disable_ajax_record_details']) {
                echo '	<th><!-- Expand record column --></th>
				';
            }
            $results =& $this->getResults();
            $perms = array();
            $numCols = 0;
            $rowHeaderHtml = $this->renderRowHeader();
            if (isset($rowHeaderHtml)) {
                echo $rowHeaderHtml;
            } else {
                foreach ($this->_columns as $key) {
                    if (in_array($key, $this->_columns)) {
                        if (!($perms[$key] = Dataface_PermissionsTool::checkPermission('list', $this->_table, array('field' => $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('-sort' => $sort_query);
                        $link = Dataface_LinkTool::buildLink($sq);
                        $numCols++;
                        $label = $this->_table->getFieldProperty('column:label', $key);
                        $legend = $this->_table->getFieldProperty('column:legend', $key);
                        if ($legend) {
                            $legend = '<span class="column-legend">' . htmlspecialchars($legend) . '</span>';
                        }
                        if (!$label) {
                            $label = $this->_table->getFieldProperty('widget:label', $key);
                        }
                        echo "<th class=\"{$class}\"><a href=\"{$link}\">" . htmlspecialchars($label) . "</a> {$legend}</th>";
                    }
                }
            }
            echo "</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>\n\t\t\t\t";
            $cursor = $this->_resultSet->start();
            $results->reset();
            $baseQuery = array();
            foreach ($_GET as $key => $value) {
                if (strpos($key, '-') !== 0) {
                    $baseQuery[$key] = $value;
                }
            }
            $evenRow = false;
            while ($results->hasNext()) {
                $rowClass = $evenRow ? 'even' : 'odd';
                $evenRow = !$evenRow;
                $record =& $results->next();
                if (!$record->checkPermission('view')) {
                    $cursor++;
                    unset($record);
                    continue;
                }
                $rowClass .= ' ' . $this->getRowClass($record);
                $query = array_merge($baseQuery, array("-action" => "browse", "-relationship" => null, "-cursor" => $cursor++));
                if ($record->checkPermission('link')) {
                    if (@$app->prefs['result_list_use_geturl']) {
                        $link = $record->getURL('-action=view');
                    } else {
                        $link = Dataface_LinkTool::buildLink($query) . '&-recordid=' . urlencode($record->getId());
                    }
                } else {
                    $del =& $record->_table->getDelegate();
                    if ($del and method_exists($del, 'no_access_link')) {
                        $link = $del->no_access_link($record);
                    } else {
                        $link = null;
                    }
                }
                $recordid = $record->getId();
                echo "<tr class=\"listing {$rowClass}\">";
                if ($canSelect) {
                    echo '<td><input class="rowSelectorCheckbox" id="rowSelectorCheckbox:' . $record->getId() . '" type="checkbox"></td>';
                }
                if (!@$app->prefs['disable_ajax_record_details']) {
                    echo '<td>';
                    echo '<script language="javascript" type="text/javascript"><!--
							registerRecord(\'' . addslashes($recordid) . '\',  ' . $record->toJS(array()) . ');
							//--></script>
							<img src="' . DATAFACE_URL . '/images/treeCollapsed.gif" onclick="resultList.showRecordDetails(this, \'' . addslashes($recordid) . '\')"/>';
                    $at =& Dataface_ActionTool::getInstance();
                    $actions = $at->getActions(array('category' => 'list_row_actions', 'record' => &$record));
                    //print_r($actions);
                    if (count($actions) > 0) {
                        echo ' <span class="row-actions">';
                        foreach ($actions as $action) {
                            echo '<a href="' . htmlspecialchars($action['url']) . '" class="' . htmlspecialchars($action['class']) . ' ' . (@$action['icon'] ? 'with-icon' : '') . '" ' . (@$action['icon'] ? ' style="' . htmlspecialchars('background-image: url(' . $action['icon'] . ')') . '"' : '') . (@$action['target'] ? ' target="' . htmlspecialchars($action['target']) . '"' : '') . ' title="' . htmlspecialchars(@$action['description'] ? $action['description'] : $action['label']) . '"><span>' . htmlspecialchars($action['label']) . '</span></a> ';
                        }
                        echo '</span>';
                    }
                    echo '</td>';
                    unset($at, $actions);
                }
                $rowContentHtml = $this->renderRow($record);
                if (isset($rowContentHtml)) {
                    echo $rowContentHtml;
                } else {
                    //$expandTree=false; // flag to indicate when we added the expandTree button
                    //if ( @$app->prefs['enable_ajax_record_details'] === 0 ){
                    //	$expandTree = true;
                    //}
                    foreach ($this->_columns as $key) {
                        $thisField =& $record->_table->getField($key);
                        if (!$perms[$key]) {
                            continue;
                        }
                        $val = $this->renderCell($record, $key);
                        if ($record->checkPermission('edit', array('field' => $key)) and !$record->_table->isMetaField($key)) {
                            $editable_class = 'df__editable_wrapper';
                        } else {
                            $editable_class = '';
                        }
                        if (!@$thisField['noLinkFromListView'] and $link and $val) {
                            $val = "<a href=\"{$link}\" class=\"unmarked_link\">" . $val . "</a>";
                            $editable_class = '';
                        } else {
                        }
                        if (@$thisField['noEditInListView']) {
                            $editable_class = '';
                        }
                        echo "<td id=\"td-" . rand() . "\" class=\"{$rowClass} {$editable_class}\">&nbsp;{$val}</td>";
                        unset($thisField);
                    }
                }
                echo "</tr>";
                echo "<tr class=\"listing {$rowClass}\" style=\"display:none\" id=\"{$recordid}-row\">";
                if ($canSelect) {
                    echo "<td><!--placeholder for checkbox col --></td>";
                }
                echo "<td colspan=\"" . ($numCols + 1) . "\" id=\"{$recordid}-cell\"></td>\n\t\t\t\t\t  </tr>";
                unset($record);
            }
            if (@$app->prefs['enable_resultlist_add_row']) {
                echo "<tr id=\"add-new-row\" df:table=\"" . htmlspecialchars($this->_table->tablename) . "\">";
                if ($canSelect) {
                    $colspan = 2;
                } else {
                    $colspan = 1;
                }
                echo "<td colspan=\"{$colspan}\"><script language=\"javascript\">require(DATAFACE_URL+'/js/addable.js')</script><a href=\"#\" onclick=\"df_addNew('add-new-row');return false;\">" . df_translate('scripts.GLOBAL.LABEL_ADD_ROW', "Add Row") . "</a></td>";
                foreach ($this->_columns as $key) {
                    echo "<td><span df:field=\"" . htmlspecialchars($key) . "\"></span></td>";
                }
                echo "</tr>";
            }
            echo "</tbody>\n\t\t\t\t</table>";
            if ($canSelect) {
                echo '<form id="result_list_selected_items_form" method="post" action="' . df_absolute_url(DATAFACE_SITE_HREF) . '">';
                $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="' . urlencode($key) . '" value="' . htmlspecialchars($val) . '" />';
                }
                echo '<input type="hidden" name="--selected-ids" id="--selected-ids" />';
                echo '<input type="hidden" name="-from" id="-from" value="' . $q['-action'] . '" />';
                echo '<input type="hidden" name="--redirect" value="' . base64_encode($app->url('')) . '" />';
                echo '</form>';
                import('Dataface/ActionTool.php');
                $at =& Dataface_ActionTool::getInstance();
                $actions = $at->getActions(array('category' => 'selected_result_actions'));
                if (count($actions) > 0) {
                    echo '<div id="selected-actions">' . df_translate('scripts.Dataface_ResultList.MESSAGE_WITH_SELECTED', "With Selected") . ': <ul class="selectedActionsMenu" id="result_list-selectedActionsMenu">';
                    foreach ($actions as $action) {
                        $img = '';
                        if (@$action['icon']) {
                            $img = '<img src="' . $action['icon'] . '"/>';
                        }
                        if (!@$action['onclick'] and !$action['url']) {
                            $action['onclick'] = "return actOnSelected('result_list', '" . @$action['name'] . "'" . (@$action['confirm'] ? ", function(){return confirm('" . addslashes($action['confirm']) . "');}" : "") . ")";
                        }
                        echo <<<END
\t\t\t\t\t\t<li id="action-{$action['id']}"><a href="{$action['url']}" onclick="{$action['onclick']}" title="{$action['description']}">{$img}{$action['label']}</a></li>
END;
                    }
                    echo '</ul></div>';
                }
            }
            if (@$app->prefs['use_old_resultlist_controller']) {
                echo '<div class="resultlist-controller" id="resultlist-controller-bottom">';
                echo $controller;
                echo '</div>';
            }
            $out = ob_get_contents();
            ob_end_clean();
        } else {
            if (@$app->prefs['use_old_resultlist_controller']) {
                ob_start();
                df_display(array(), 'Dataface_ResultListController.html');
                $out = ob_get_contents();
                ob_end_clean();
            } else {
                $out = '';
            }
            $out .= "<p style=\"clear:both\">" . df_translate('scripts.GLOBAL.MESSAGE_NO_MATCH', "No records matched your request.") . "</p>";
        }
        return $out;
    }
Beispiel #5
0
 /**
  * Renders the entire treetable as HTML.
  */
 function toHtml($depth = 3, $treetableid = 'treetable')
 {
     $app =& Dataface_Application::getInstance();
     if (isset($this->relationship)) {
         $rel =& $this->record->_table->getRelationship($this->relationship);
         $table = $rel->getDomainTable();
         if (PEAR::isError($table)) {
             $destTables =& $rel->getDestinationTables();
             $table = $destTables[0]->tablename;
         }
     } else {
         $table = $this->record->_table->tablename;
         $rel =& $this->record->_table->getChildrenRelationship();
     }
     //echo "Def order col = $default_order_column";
     //ob_start();
     //$moveUpForm = ob_get_contents();
     //ob_end_clean();
     $resultList = new Dataface_ResultList($table);
     $columns = $resultList->_columns;
     ob_start();
     $default_order_column = $rel->getOrderColumn();
     if (isset($default_order_column)) {
         //echo "<script language=\"javascript\" type=\"text/javascript\"><!--";
         df_display(array('redirectUrl' => $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']), 'Dataface_MoveUpForm.html');
         //echo "//--></script>";
     }
     if (!defined('Dataface_TreeTable_JAVASCRIPT_LOADED')) {
         define('Dataface_TreeTable_JAVASCRIPT_LOADED', true);
         echo '<script language="javascript" type="text/javascript" src="' . DATAFACE_URL . '/js/TreeTable.js"></script>';
     }
     echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="GET" onsubmit="return validateTTForm(this);">';
     echo "<table width=\"100%\" id=\"{$treetableid}\" class=\"treetable\">";
     echo "<thead><tr><th><!-- checkbox column --></th><th><!-- Icon column --></th><th>Title</th>";
     foreach ($columns as $col) {
         echo "<th>{$col}</th>";
     }
     echo "</tr></thead><tbody>";
     echo $this->getSubrowsAsHTML('', $depth, $treetableid);
     echo "</tbody></table>";
     import('Dataface/ActionTool.php');
     $actionsTool =& Dataface_ActionTool::getInstance();
     $actions = $actionsTool->getActions(array('category' => 'selected_records_actions'));
     if (count($actions) > 0) {
         echo "   Perform on selected records:\n\t\t\t<select name=\"-action\">";
         foreach (array_keys($actions) as $i) {
             echo "<option value=\"" . $actions[$i]['name'] . "\">" . $actions[$i]['label'] . "</option>\n\t\t\t\t";
         }
         echo "\n\t\t\t\n\t\t\t</select>\n\t\t\t\n\t\t\t";
         echo "<input type=\"submit\" value=\"Submit\"/>";
     }
     import('Dataface/Utilities.php');
     // We need to build a query.
     $q = array('-table' => $this->record->_table->tablename);
     foreach (array_keys($this->record->_table->keys()) as $tkey) {
         $q['--__keys__'][$tkey] = '=' . $this->record->strval($tkey);
     }
     $q['-relationship'] = $this->relationship;
     echo Dataface_Utilities::query2html($q, array('-action'));
     echo '<input type="hidden" name="-redirect" value="' . $_SERVER['REQUEST_URI'] . '"/>';
     echo "</form>";
     echo "\n\t\t<script language=\"javascript\" type=\"text/javascript\t\"><!--\n\t\t\tTreeTable.prototype.trees['{$treetableid}'] = new TreeTable('{$treetableid}','');\n\t\t//--></script>\n\t\t";
     $out = ob_get_contents();
     ob_end_clean();
     return $out;
 }
Beispiel #6
0
 /**
  * @brief Returns the actions for this table.
  * @param array $params An associative array of options.  Possible keys include:
  * @code
  *		record => reference to a Dataface_Record or Dataface_RelatedRecord object
  *		relationship => The name of a relationship.
  *		category => A name of a category for the actions to be returned.
  * @endcode
  * @return array An associative array of action data structures.
  *
  * @see Dataface_ActionTool
  *
  */
 function getActions(&$params, $noreturn = false)
 {
     import('Dataface/ActionTool.php');
     $actionsTool =& Dataface_ActionTool::getInstance();
     if (!$this->_actionsLoaded) {
         $this->_actionsLoaded = true;
         import('Dataface/ConfigTool.php');
         $configTool =& Dataface_ConfigTool::getInstance();
         $actions =& $configTool->loadConfig('actions', $this->tablename);
         //print_r($actions);
         //$singularLabel = $this->getSingularLabel();
         //$pluralLabel = $this->getLabel();
         foreach ($actions as $key => $action) {
             $action['table'] = $this->tablename;
             $action['name'] = $key;
             if (!isset($action['id'])) {
                 $action['id'] = $action['name'];
             }
             if (!isset($action['label'])) {
                 $action['label'] = str_replace('_', ' ', ucfirst($action['name']));
             }
             if (!isset($action['accessKey'])) {
                 $action['accessKey'] = substr($action['name'], 0, 1);
             }
             if (!isset($action['label_i18n'])) {
                 $action['label_i18n'] = 'action:' . $action['name'] . ' label';
             }
             if (!isset($action['description_i18n'])) {
                 $action['description_i18n'] = 'action:' . $action['name'] . ' description';
             }
             if (isset($action['description'])) {
                 $action['description'] = df_translate('actions.' . $action['name'] . '.description', $action['description']);
             }
             if (isset($action['label'])) {
                 //$action['label'] = df_translate('actions.'.$action['name'].'.label',$action['label'], array('table_label_singular'=>$singularLabel, 'table_label_plural'=>$pluralLabel));
                 $action['label'] = df_translate('actions.' . $action['name'] . '.label', $action['label']);
             }
             $actionsTool->addAction($key, $action);
         }
     }
     $params['table'] = $this->tablename;
     if ($noreturn) {
         return true;
     }
     return $actionsTool->getActions($params);
 }
Beispiel #7
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;
    }
Beispiel #8
0
 function actions_menu($params, &$smarty)
 {
     $context = array();
     if (isset($params['id'])) {
         $context['id'] = $params['id'];
         unset($params['id']);
     } else {
         $context['id'] = '';
     }
     if (isset($params['class'])) {
         $context['class'] = $params['class'];
         unset($params['class']);
     } else {
         $context['class'] = '';
     }
     if (isset($params['id_prefix'])) {
         $context['id_prefix'] = $params['id_prefix'];
         unset($params['id_prefix']);
     } else {
         $context['id_prefix'] = '';
     }
     if (isset($params['selected_action'])) {
         $context['selected_action'] = $params['selected_action'];
         unset($params['selected_action']);
     } else {
         $context['selected_action'] = '';
     }
     if (isset($params['actions'])) {
         $addon_actions =& $params['actions'];
     } else {
         $addon_actions = null;
     }
     //$params['var'] = 'actions';
     //$this->actions($params, $smarty);
     //print_r($
     import('Dataface/ActionTool.php');
     $actionTool =& Dataface_ActionTool::getInstance();
     $actions = $actionTool->getActions($params);
     if ($addon_actions !== null) {
         $p2 = $params;
         unset($p2['category']);
         $actions = array_merge($actions, $actionTool->getActions($p2, $addon_actions));
         usort($actions, array(&$actionTool, '_compareActions'));
     }
     foreach ($actions as $k => $a) {
         if (@$a['subcategory']) {
             $p2 = $params;
             $p2['category'] = $a['subcategory'];
             $subactions = $actionTool->getActions($p2);
             $actions[$k]['subactions'] = $subactions;
         }
     }
     //print_r($actions);
     $context['actions'] =& $actions;
     //$smarty->assign($context);
     if (isset($params['mincount']) and intval($params['mincount']) > count($context['actions'])) {
         return;
     }
     if (isset($params['maxcount']) and intval($params['maxcount']) < count($context['actions'])) {
         $more = array('name' => 'more', 'label' => df_translate('actions_menu.more.label', 'More'), 'subactions' => array(), 'description' => df_translate('actions_menu.more.description', 'More actions...'), 'url' => '#');
         $existing = array();
         $i = 0;
         $lastExistingKey = null;
         foreach ($actions as $k => $a) {
             $i++;
             if ($i < $params['maxcount']) {
                 $existing[$k] = $a;
                 $lastExistingKey = $k;
             } else {
                 $more['subactions'][$k] = $a;
             }
         }
         $existing['more'] = $more;
         $context['actions'] = $existing;
     }
     $smarty->display($context, 'Dataface_ActionsMenu.html');
 }
Beispiel #9
0
    function toHtml()
    {
        $app =& Dataface_Application::getInstance();
        $query =& $app->getQuery();
        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();
        }
        $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;
        }
        //echo $sort_columns_str;exit;
        unset($query);
        $skinTool =& Dataface_SkinTool::getInstance();
        $resultController =& $skinTool->getResultController();
        $s =& $this->_table;
        $r =& $this->_relationship->_schema;
        $fkeys = $this->_relationship->getForeignKeyValues();
        $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();
        $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 . " on line " . __LINE__ . " of file " . __FILE__);
            return $records;
        }
        ob_start();
        //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));
        if (Dataface_PermissionsTool::edit($this->_record) or @$perms['add new related record'] or @$perms['add existing related record']) {
            $query = array('-action' => 'new_related_record');
            $link = Dataface_LinkTool::buildLink($query);
            $domainTable = $this->_relationship->getDomainTable();
            $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');
                $link2 = Dataface_LinkTool::buildLink($query2);
                $destTables = $this->_relationship->getDestinationTables();
                $importTablename = $destTables[0]->tablename;
            }
            if (!PEAR::isError($importTablename)) {
                $importTable =& Dataface_Table::loadTable($importTablename);
                $query3 = array('-action' => 'import');
                $link3 = Dataface_LinkTool::buildLink($query3);
            }
            echo "<div id=\"relatedActionsWrapper\" class=\"contentActions\"><ul id=\"relatedActions\">";
            if ($this->_relationship->supportsAddNew() and @$perms['add new related record']) {
                echo "<li id=\"addNew\"><a id=\"add_new_related_record\" href=\"{$link}\">" . df_translate('scripts.Dataface.RelatedList.toHtml.LABEL_ADD_NEW_RELATED_RECORD', "Add New " . ucfirst($this->_relationship_name) . " Record", array('relationship' => ucfirst($this->_relationship_name))) . "</a></li>";
            }
            if ($this->_relationship->supportsAddExisting() and isset($query2) and @$perms['add existing related record']) {
                echo "<li id=\"addExisting\"><a id=\"add_existing_related_record\" href=\"{$link2}\">" . df_translate('scripts.Dataface.RelatedList.toHtml.LABEL_ADD_EXISTING_RELATED_RECORD', "Add Existing " . ucfirst($this->_relationship_name) . " Record", array('relationship' => ucfirst($this->_relationship_name))) . "</a></li>";
            }
            if (isset($query3) and count($importTable->getImportFilters()) > 0) {
                echo "<li id=\"import\"><a id=\"import_related_records\" href=\"{$link3}\">" . df_translate('scripts.Dataface.RelatedList.toHtml.LABEL_IMPORT_RELATED_RECORDS', "Import " . ucfirst($this->_relationship_name) . " Records", array('relationship' => ucfirst($this->_relationship_name))) . "</a></li>";
            }
            echo "</ul></div>";
        }
        $out = ob_get_contents();
        ob_end_clean();
        ob_start();
        $imgIcon = DATAFACE_URL . '/images/search_icon.gif';
        $searchSrc = DATAFACE_URL . '/js/Dataface/RelatedList/search.js';
        $relname = $this->_relationship_name;
        echo <<<END
\t\t<div class="result-tools" style="float:left">
\t\t\t<script language="javascript" type="text/javascript" src="{$searchSrc}"></script>
\t\t\t<a href="#" onclick="Dataface.RelatedList.showSearch('{$relname}', document.getElementById('related_find_wrapper')); return false;" title="Filter these results"><img src="{$imgIcon}" alt="Filter" /></a>
\t\t\t
\t\t</div>
END;
        echo '<div class="result-stats">';
        $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));
        echo df_translate('scripts.Dataface.RelatedList.toHtml.MESSAGE_FOUND', "<b>Found</b> " . $num_related_records . " Records in relationship <i>" . $this->_relationship_name . "</i>", array('num' => $num_related_records, 'relationship' => $this->_relationship_name)) . "<br/>" . df_translate('scripts.Dataface.RelatedList.toHtml.MESSAGE_NOW_SHOWING', "<b>Now Showing</b> " . $now_showing_start . " to " . $now_showing_finish, array('start' => $now_showing_start, 'finish' => $now_showing_finish)) . "</div>\n\t\t\t<div class=\"limit-field\">\n\t\t\t";
        echo $resultController->limitField('related:');
        echo "</div>\n\t\t\t<div class=\"prev-link\">" . $this->_backButtonHtml() . "</div>\n\t\t\t<div class=\"next-link\">" . $this->_forwardButtonHtml() . "</div>\n\t\t";
        import('Dataface/ActionTool.php');
        $at =& Dataface_ActionTool::getInstance();
        $actions = $at->getActions(array('category' => 'related_list_actions'));
        echo <<<END
\t\t<div class="result-list-actions">
\t\t<ul class="icon-only" id="result-list-actions">
END;
        foreach ($actions as $action) {
            if (@$action['onclick']) {
                $onclick = 'onclick="' . htmlspecialchars($action['onclick']) . '"';
            } else {
                $onclick = '';
            }
            echo <<<END
\t\t\t  <li id="result-list-actions-{$action['id']}" class="plain">
\t\t\t
\t\t\t<a id="result-list-actions-{$action['id']}-link"href="{$action['url']}" {$onclick}
\t\t\t   accesskey="e" title="{$action['description']}">
\t\t\t   <img id="result-list-actions-{$action['id']}-icon"src="{$action['icon']}" alt="{$action['label']}"/>                   
\t\t\t\t<span class="action-label">{$action['label']}</span>
\t\t\t</a>
\t\t  </li>
END;
        }
        echo <<<END
\t\t</ul>
\t\t
\t\t</div>
END;
        $relatedResultController = ob_get_contents();
        ob_end_clean();
        ob_start();
        //echo '<div style="clear: both"/>';
        echo '<div class="resultlist-controller">';
        echo $relatedResultController;
        echo "</div>";
        import('Dataface/ActionTool.php');
        $at =& Dataface_ActionTool::getInstance();
        $selected_actions = $at->getActions(array('category' => 'selected_related_result_actions'));
        if ($this->_relationship->_schema['list']['type'] == 'treetable') {
            import('Dataface/TreeTable.php');
            $treetable = new Dataface_TreeTable($this->_record, $this->_relationship->getName());
            echo $treetable->toHtml();
        } else {
            echo $moveUpForm;
            if ($this->_where) {
                $filterQuery =& $app->getQuery();
                echo '<div>Showing matches for query <em>&quot;' . htmlspecialchars($filterQuery['-related:search']) . '&quot;</em>
				<a href="' . $app->url('-related:search=') . '" title="Remove this filter to show all records in this relationship">
					<img src="' . DATAFACE_URL . '/images/delete.gif" alt="Remove filter" />
				</a>
				</div>';
            }
            echo '<div style="display:none" id="related_find_wrapper"></div>';
            if (count($records) > 0) {
                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><input type="checkbox" onchange="toggleSelectedRows(this,\'relatedList\');"></th>
					';
                }
                $cols = array_keys(current($records));
                $col_tables = array();
                $table_keys = array();
                $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 =& $s->getField($fullpath);
                    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 (PEAR::isError($field)) {
                        $field->addUserInfo("Error getting field info for field {$key} in RelatedList::toHtml() on line " . __LINE__ . " of file " . __FILE__);
                        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">' . htmlspecialchars($field['column']['legend']) . '</span>';
                    }
                    echo '<th><a href="' . $link . '">' . $field['widget']['label'] . "</a> {$legend}</th>\n";
                    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] =& $s->getField($fullpaths[$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';
                    }
                    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();
                    echo "<tr class=\"listing {$rowClass}\" style=\"{$style}\" id=\"row_{$rrecid}\">";
                    if (count($selected_actions) > 0) {
                        echo '
						<td class="' . $rowClass . ' viewableColumn" nowrap>
							<input class="rowSelectorCheckbox" id="rowSelectorCheckbox:' . $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']);
                        $link = $srcRecord->getURL('-action=browse');
                        /*
                        if ( isset($link_queries[$col_tables[$key]]) ){
                        	$query = $link_queries[$col_tables[$key]];
                        	$failed = false;
                        } else {
                        	
                        	$query = array( "-action"=>"browse", "-relationship"=>null, "-cursor"=>0, "-table"=>$col_tables[$key]) ;
                        	$failed = false;
                        		// flag to indicate if we failed to generate appropriate link
                        	
                        	foreach ( $table_keys[$col_tables[$key]] as $table_key ){
                        		$query[$table_key] = "=".$this->_record->getValueAsString($this->_relationship_name.'.'.$table_key, $i, $this->_where, $sort_columns_str);
                        		if ( $query[$table_key] == '=' ){
                        			if ( isset( $fkeys[$col_tables[$key]][$table_key]) ){
                        				$query[$table_key] = $this->_record->parseString($fkeys[$col_tables[$key]][$table_key]);
                        			} else {
                        				$failed = true;
                        			}
                        		}
                        	}
                        	$link_queries[$col_tables[$key]] = $query;
                        }
                        
                        if ( $failed ){
                        	$link = "#";
                        } else {
                        	
                        	$link = Dataface_LinkTool::buildLink($query, false);
                        }
                        */
                        //$val = '';
                        $val = $this->_record->preview($fullpath, $i, 255, $this->_where, $sort_columns_str);
                        $title = "";
                        if ($key == $default_order_column) {
                            unset($field);
                            unset($srcRecord);
                            continue;
                        } else {
                            if ($val != 'NO ACCESS') {
                                $accessClass = 'viewableColumn';
                            } else {
                                $accessClass = '';
                            }
                            $cellClass = 'resultListCell resultListCell--' . $key;
                            $renderVal = $this->renderCell($srcRecord, $field['Field']);
                            if (isset($renderVal)) {
                                $val = $renderVal;
                            } else {
                                if ($link and !@$field['noLinkFromListView']) {
                                    $val = "<a href=\"{$link}\" title=\"" . htmlspecialchars($title) . "\">" . $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>";
                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="' . htmlspecialchars($val) . '">';
                }
                echo '<input type="hidden" name="--selected-ids" id="--selected-ids">';
                echo '<input type="hidden" name="-from" id="-from" value="' . $query['-action'] . '">';
                echo '</form>';
                if (count($selected_actions) > 0) {
                    echo '<div id="selected-actions">' . df_translate('scripts.GLOBAL.LABEL_WITH_SELECTED', 'With Selected') . ': <ul class="selectedActionsMenu" id="result_list-selectedActionsMenu">';
                    foreach ($selected_actions as $action) {
                        echo <<<END
\t\t\t\t\t\t<li id="action-{$action['id']}"><a href="{$action['url']}" title="{$action['description']}">{$action['label']}</a></li>
END;
                    }
                    echo '</ul></div>';
                }
                echo '<div class="resultlist-controller">';
                echo $relatedResultController;
                echo '</div>';
                // 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';
                $scriptaculous_url = DATAFACE_URL . '/js/scriptaculous/src/scriptaculous.js';
                $effects_url = DATAFACE_URL . '/js/scriptaculous/src/effects.js';
                $dragdrop_url = DATAFACE_URL . '/js/scriptaculous/src/dragdrop.js';
                $thisRecordID = $this->_record->getId();
                echo <<<END
\t\t\t\t<script language="javascript" src="{$prototype_url}"></script>
\t\t\t\t<script language="javascript" src="{$scriptaculous_url}"></script>
\t\t\t\t<script language="javascript" src="{$effects_url}"></script>
\t\t\t\t<script language="javascript" src="{$dragdrop_url}"></script>
\t\t\t\t<script language="javascript"><!--
\t\t\t\tfunction removeUnauthorizedColumns(){
\t\t\t\t\tvar relatedList = document.getElementById('relatedList');
\t\t\t\t\tvar trs = relatedList.getElementsByTagName('tr');
\t\t\t\t\tvar viewableColumns = [];
\t\t\t\t\tvar numCols = 0;
\t\t\t\t\tfor (var i=0; i<trs.length; i++){
\t\t\t\t\t\tvar tr = trs[i];
\t\t\t\t\t\tvar tds = tr.getElementsByTagName('td');
\t\t\t\t\t\tfor (var j=0; j<tds.length; j++){
\t\t\t\t\t\t\tvar td = tds[j];
\t\t\t\t\t\t\tif ( td.className.indexOf('viewableColumn') >= 0 ){
\t\t\t\t\t\t\t\tviewableColumns[j] = true;
\t\t\t\t\t\t\t}
\t\t\t\t\t\t\tnumCols = j;
\t\t\t\t\t\t}
\t\t\t\t\t}
\t\t\t\t\tfor (var j=viewableColumns.length; j<=numCols; j++){
\t\t\t\t\t\tviewableColumns[j] = false;
\t\t\t\t\t}
\t\t\t\t\t
\t\t\t\t\t
\t\t\t\t\tfor (var i=0; i<trs.length; i++){
\t\t\t\t\t\tvar tds = trs[i].getElementsByTagName('td');
\t\t\t\t\t\tif ( tds.length <= 0 ){
\t\t\t\t\t\t\tvar tds = trs[i].getElementsByTagName('th');
\t\t\t\t\t\t}
\t\t\t\t\t\t
\t\t\t\t\t\tfor (var j=0; j<viewableColumns.length; j++){
\t\t\t\t\t\t\tif ( !viewableColumns[j] ){
\t\t\t\t\t\t\t\ttds[j].style.display = 'none';
\t\t\t\t\t\t\t}
\t\t\t\t\t\t}
\t\t\t\t\t\t
\t\t\t\t\t}
\t\t\t\t}
\t\t\t\tremoveUnauthorizedColumns();
\t\t\t\t
\t\t\t\t
\t\t\t\tif ( {$sortable_js} ){
\t\t\t\t\tSortable.create("relatedList-body",
\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\tdropOnEmpty:true,
\t\t\t\t\t\t\t\tconstraint:false, 
\t\t\t\t\t\t\t\t//handle:'move-handle',
\t\t\t\t\t\t\t\ttag:'tr',
\t\t\t\t\t\t\t\tonUpdate: function(container){
\t\t\t\t\t\t\t\t\t
\t\t\t\t\t\t\t\t\tvar params = Sortable.serialize('relatedList-body');
\t\t\t\t\t\t\t\t\tparams += '&'+window.location.search.substring(1);
\t\t\t\t\t\t\t\t\t
\t\t\t\t\t\t\t\t\tparams += '&-action=reorder_related_records';//&--recordid='+escape('{$thisRecordID}');
\t\t\t\t\t\t\t\t\t
\t\t\t\t\t\t\t\t\tnew Ajax.Request(
\t\t\t\t\t\t\t\t\t\tDATAFACE_SITE_HREF, {
\t\t\t\t\t\t\t\t\t\t\tmethod: 'post', 
\t\t\t\t\t\t\t\t\t\t\tparameters: params, 
\t\t\t\t\t\t\t\t\t\t\tonSuccess: function(transport){
\t\t\t\t\t\t\t\t\t\t\t    
\t\t\t\t\t\t\t\t\t\t\t\t//document.getElementById('details-controller').innerHTML = transport.responseText;
\t\t\t\t\t\t\t\t\t\t\t},
\t\t\t\t\t\t\t\t\t\t\tonFailure:function(){
\t\t\t\t\t\t\t\t\t\t\t\talert('Failed to sort records.');
\t\t\t\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t\t);
\t\t\t\t\t\t\t\t\t
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t//only:'movable'
\t\t\t\t\t\t\t});
\t\t\t\t\t\t//Sortable.create("dataface-sections-main",
\t\t\t\t\t\t//{dropOnEmpty:true,constraint:false, handle:'movable-handle',tag:'div',only:'movable', onUpdate:updateSections});
\t\t\t\t}\t
\t\t\t\t
\t\t\t\t//--></script>
\t\t\t\t
END;
            } else {
                echo "<p>" . df_translate('scripts.GLOBAL.NO_RECORDS_MATCHED_REQUEST', 'No records matched your request.') . "</p>";
            }
        }
        $out .= ob_get_contents();
        ob_end_clean();
        return $out;
    }
Beispiel #10
0
 function actions_menu($params, &$smarty)
 {
     $context = array();
     if (isset($params['id'])) {
         $context['id'] = $params['id'];
         unset($params['id']);
     } else {
         $context['id'] = '';
     }
     if (isset($params['class'])) {
         $context['class'] = $params['class'];
         unset($params['class']);
     } else {
         $context['class'] = '';
     }
     if (isset($params['id_prefix'])) {
         $context['id_prefix'] = $params['id_prefix'];
         unset($params['id_prefix']);
     } else {
         $context['id_prefix'] = '';
     }
     if (isset($params['selected_action'])) {
         $context['selected_action'] = $params['selected_action'];
         unset($params['selected_action']);
     } else {
         $context['selected_action'] = '';
     }
     if (isset($params['actions'])) {
         $addon_actions =& $params['actions'];
     } else {
         $addon_actions = null;
     }
     //$params['var'] = 'actions';
     //$this->actions($params, $smarty);
     //print_r($
     import('Dataface/ActionTool.php');
     $actionTool =& Dataface_ActionTool::getInstance();
     $actions = $actionTool->getActions($params);
     if ($addon_actions !== null) {
         $p2 = $params;
         unset($p2['category']);
         $actions = array_merge($actions, $actionTool->getActions($p2, $addon_actions));
         usort($actions, array(&$actionTool, '_compareActions'));
     }
     //print_r($actions);
     $context['actions'] =& $actions;
     //$smarty->assign($context);
     if (isset($params['mincount']) and intval($params['mincount']) > count($context['actions'])) {
         return;
     }
     $smarty->display($context, 'Dataface_ActionsMenu.html');
 }
Beispiel #11
0
    function printTranslationStatusAlert($record, $language = null)
    {
        if (!isset($language)) {
            $app = Dataface_Application::getInstance();
            $language = $app->_conf['lang'];
        }
        $trec = $this->getTranslationRecord($record, $language);
        if (!$trec) {
            return;
        }
        $status = $trec->val('translation_status');
        switch ($status) {
            case TRANSLATION_STATUS_MACHINE:
                $msg = df_translate('machine translation warning', "This section was translated using a machine translator and may contain errors.");
                break;
            case TRANSLATION_STATUS_NEEDS_UPDATE_MACHINE:
                $msg = df_translate('old machine translation warning', "This section was translated using a machine translator and may contain errors.  The original version has also been modified since this translation was completed so this translation may be out of date.");
                break;
            case TRANSLATION_STATUS_UNVERIVIED:
                $msg = df_translate('unverified translation warning', "This translation has not been verified by an administrator yet.");
                break;
            case TRANSLATION_STATUS_NEEDS_UPDATE_UNVERIFIED:
                $msg = df_translate('old unverified translation warning', "This translation has not been verified by an administrator yet.  The original version has also been modified since this translation was completed so this translation may be out of date.");
                break;
            case TRANSLATION_STATUS_NEEDS_UPDATE:
                $msg = df_translate('old translation warning', "This translation may be out of date as the original version has been modified since this was last translated.");
                break;
        }
        if (!@$msg) {
            return;
        }
        import('Dataface/ActionTool.php');
        $at = Dataface_ActionTool::getInstance();
        $actions = $at->getActions(array('category' => 'translation_warning_actions', 'record_id' => $record->getId()));
        $actions_html = "<ul class=\"translation_options\">";
        foreach ($actions as $action) {
            $actions_html .= <<<END
\t\t\t\t<li><a href="{$action['url']}" title="{$action['description']}">{$action['label']}</a></li>
END;
        }
        $actions_html .= '</ul>';
        echo <<<END
\t\t
\t\t<div class="portalMessage">
\t\t\t{$msg}
\t\t\t{$actions_html}
\t\t</div>
END;
    }
Beispiel #12
0
 function &getAction()
 {
     import('Dataface/ActionTool.php');
     $actionTool = Dataface_ActionTool::getInstance();
     return $actionTool->getAction(array('name' => $this->_query['-action']));
 }
Beispiel #13
0
 /**
  * @brief Handle a request.  This method is the starting point for all Dataface application requests.
  * It will delegate the request to the appropriate handler.
  * The order of delegation is as follows:
  *  -# Uses the ActionTool to check permissions for the action.  If permissions are not granted,
  *		dispatch the error handler.  If permissions are granted then we continue down the delegation
  *		chain.
  *  -# If the current table's delegate class defines a handleRequest() method, then call that.
  *	-# If the current table's delegate class does not have a handleRequest() method or that method
  *		returns a PEAR_Error object with code E_DATAFACE_REQUEST_NOT_HANDLED, then check for a handler
  *		bearing the name of the action in one of the actions directories.  Check the directories 
  *		in the following order:
  *		a. <site url>/tables/<table name>/actions
  *		b. <site url>/actions
  *		b. <dataface url>/actions
  *
  * @param boolean $disableCache Whether to disable the cache or not for this request.
  *
  * @see ApplicationDelegateClass::beforeHandleRequest()
  */
 function handleRequest($disableCache = false)
 {
     if (!$disableCache and @$_GET['-action'] != 'getBlob' and isset($this->_conf['_output_cache']) and @$this->_conf['_output_cache']['enabled'] and count($_POST) == 0) {
         import('Dataface/OutputCache.php');
         $oc = new Dataface_OutputCache($this->_conf['_output_cache']);
         $oc->ob_start();
     }
     import('Dataface/ActionTool.php');
     import('Dataface/PermissionsTool.php');
     import('Dataface/Table.php');
     if (isset($this->_conf['_modules']) and count($this->_conf['_modules']) > 0) {
         $mt = Dataface_ModuleTool::getInstance();
         foreach ($this->_conf['_modules'] as $modname => $modpath) {
             $mt->loadModule($modname);
         }
     }
     $this->fireEvent('beforeHandleRequest');
     $applicationDelegate = $this->getDelegate();
     if (isset($applicationDelegate) and method_exists($applicationDelegate, 'beforeHandleRequest')) {
         // Do whatever we need to do before the request is handled.
         $applicationDelegate->beforeHandleRequest();
     }
     // Set up security filters
     $query =& $this->getQuery();
     $table = Dataface_Table::loadTable($query['-table']);
     //$table->setSecurityFilter();
     /*
      * Set up some preferences for the display of the application.
      * These can be overridden by the getPreferences() method in the
      * application delegate class.
      */
     if (isset($this->_conf['_prefs']) and is_array($this->_conf['_prefs'])) {
         $this->prefs = array_merge($this->prefs, $this->_conf['_prefs']);
     }
     if (@$this->_conf['hide_nav_menu']) {
         $this->prefs['show_tables_menu'] = 0;
     }
     if (@$this->_conf['hide_view_tabs']) {
         $this->prefs['show_table_tabs'] = 0;
     }
     if (@$this->_conf['hide_result_controller']) {
         $this->prefs['show_result_controller'] = 0;
     }
     if (@$this->_conf['hide_table_result_stats']) {
         $this->prefs['show_result_stats'] = 0;
     }
     if (@$this->_conf['hide_search']) {
         $this->prefs['show_search'] = 0;
     }
     if (!isset($this->prefs['disable_ajax_record_details'])) {
         $this->prefs['disable_ajax_record_details'] = 1;
     }
     if ($query['-action'] == 'login_prompt') {
         $this->prefs['no_history'] = 1;
     }
     if (isset($applicationDelegate) and method_exists($applicationDelegate, 'getPreferences')) {
         $this->prefs = array_merge($this->prefs, $applicationDelegate->getPreferences());
     }
     $this->prefs = array_map('intval', $this->prefs);
     // Check to make sure that this table hasn't been disallowed
     $disallowed = false;
     if (isset($this->_conf['_disallowed_tables'])) {
         foreach ($this->_conf['_disallowed_tables'] as $name => $pattern) {
             if ($pattern[0] == '/' and preg_match($pattern, $query['-table'])) {
                 $disallowed = true;
                 break;
             } else {
                 if ($pattern == $query['-table']) {
                     $disallowed = true;
                     break;
                 }
             }
         }
     }
     if ($disallowed and isset($this->_conf['_allowed_tables'])) {
         foreach ($this->_conf['_allowed_tables'] as $name => $pattern) {
             if ($pattern[0] == '/' and preg_match($pattern, $query['-table'])) {
                 $disallowed = false;
                 break;
             } else {
                 if ($pattern == $query['-table']) {
                     $disallowed = false;
                     break;
                 }
             }
         }
     }
     if ($disallowed) {
         return Dataface_Error::permissionDenied(Dataface_LanguageTool::translate("Permission Denied. This table has been disallowed in the conf.ini file", "Permission denied because this table has been disallowed in the conf.ini file '"));
     }
     $actionTool = Dataface_ActionTool::getInstance();
     //if ( $this->_conf['multilingual_content'] ){
     //import('I18Nv2/I18Nv2.php');
     //I18Nv2::autoConv();
     //}
     $params = array('table' => $query['-table'], 'name' => $query['-action']);
     if (strpos($query['-action'], 'custom_') === 0) {
         $action = array('name' => $query['-action'], 'page' => substr($query['-action'], 7), 'permission' => 'view', 'mode' => 'browse', 'custom' => true);
     } else {
         $action = $actionTool->getAction($params);
         if (is_array($action) and @$action['related'] and @$query['-relationship'] and preg_match('/relationships\\.ini/', @$action['allow_override'])) {
             // This action is to be performed on the currently selected relationship.
             $raction = $table->getRelationshipsAsActions(array(), $query['-relationship']);
             if (is_array($raction)) {
                 $action = array_merge($action, $raction);
             }
         }
         if (is_array($action) and isset($action['delegate'])) {
             $params['name'] = $query['-action'] = $action['delegate'];
             $tmp = $actionTool->getActions($params);
             unset($action);
             $action =& $tmp;
             unset($tmp);
         }
         if (is_array($action) and isset($action['auth_type'])) {
             $authTool = $this->getAuthenticationTool();
             $authTool->setAuthType($action['auth_type']);
         }
     }
     if ((PEAR::isError($action) or !@$action['permission']) and $this->_conf['security_level'] >= DATAFACE_STRICT_PERMISSIONS) {
         // The only reason getAction() will return an error is if the specified action could not be found.
         // If the application is set to use strict permissions and no action was defined in the ini file
         // then this action cannot be performed.  Strict permissions mode requires that permissions be
         // strictly set or permission will be denied.
         return Dataface_Error::permissionDenied(Dataface_LanguageTool::translate("Permission Denied. No action found in strict permissions mode", "Permission denied for action '" . $query['-action'] . "'.  No entry for this action was found in the actions.ini file.  \n\t\t\t\t\tYou are currently using strict permissions mode which requires that you define all actions that you want to use in the actions.ini file with appropriate permissions information.", array('action' => $query['-action'])));
     } else {
         if (PEAR::isError($action)) {
             $action = array('name' => $query['-action'], 'label' => $query['-action']);
         }
     }
     // Step 1:  See if the delegate class has a handler.
     $delegate = $table->getDelegate();
     $handled = false;
     if (method_exists($delegate, 'handleRequest')) {
         $result = $delegate->handleRequest();
         if (PEAR::isError($result) and $result->getCode() === DATAFACE_E_REQUEST_NOT_HANDLED) {
             $handled = false;
         } else {
             if (PEAR::isError($result)) {
                 return $result;
             } else {
                 $handled = true;
             }
         }
     }
     if (isset($action['mode']) and $action['mode']) {
         $query['-mode'] = $action['mode'];
     }
     // Step 2: Look to see if there is a handler defined
     if (isset($action['custom'])) {
         $locations = array(DATAFACE_PATH . '/actions/custom.php' => 'dataface_actions_custom');
     } else {
         $locations = array();
         $locations[Dataface_Table::getBasePath($query['-table']) . '/tables/' . basename($query['-table']) . '/actions/' . basename($query['-action']) . '.php'] = 'tables_' . $query['-table'] . '_actions_' . $query['-action'];
         $locations[DATAFACE_SITE_PATH . '/actions/' . basename($query['-action']) . '.php'] = 'actions_' . $query['-action'];
         if (isset($this->_conf['_modules']) and count($this->_conf['_modules']) > 0) {
             $mt = Dataface_ModuleTool::getInstance();
             foreach ($this->_conf['_modules'] as $modname => $modpath) {
                 $mt->loadModule($modname);
                 if ($modpath[0] == '/') {
                     $locations[dirname($modpath) . '/actions/' . basename($query['-action']) . '.php'] = 'actions_' . $query['-action'];
                 } else {
                     $locations[DATAFACE_SITE_PATH . '/' . dirname($modpath) . '/actions/' . basename($query['-action']) . '.php'] = 'actions_' . $query['-action'];
                     $locations[DATAFACE_PATH . '/' . dirname($modpath) . '/actions/' . basename($query['-action']) . '.php'] = 'actions_' . $query['-action'];
                 }
             }
         }
         $locations[DATAFACE_PATH . '/actions/' . basename($query['-action']) . '.php'] = 'dataface_actions_' . $query['-action'];
         $locations[DATAFACE_PATH . '/actions/default.php'] = 'dataface_actions_default';
     }
     $doParams = array('action' => &$action);
     //parameters to be passed to the do method of the handler
     foreach ($locations as $handlerPath => $handlerClassName) {
         if (is_readable($handlerPath)) {
             import($handlerPath);
             $handler = new $handlerClassName();
             $params = array();
             if (is_array($action) and @$action['related'] and @$query['-relationship']) {
                 $params['relationship'] = $query['-relationship'];
             }
             if (!PEAR::isError($action) and method_exists($handler, 'getPermissions')) {
                 // check the permissions on this action to make sure that we are 'allowed' to perform it
                 // this method will return an array of Strings that are names of permissions granted to
                 // the current user.
                 //echo "Checking permissions:";
                 //print_r($params);
                 $permissions = $handler->getPermissions($params);
                 //} else if ( $applicationDelegate !== null and method_exists($applicationDelegate, 'getPermissions') ){
                 //	$permissions =& $applicationDelegate->getPermissions($params);
             } else {
                 //print_r($params);
                 //print_r($action);
                 $permissions = $this->getPermissions($params);
             }
             if (isset($action['permission']) && !(isset($permissions[$action['permission']]) and $permissions[$action['permission']])) {
                 if (!$permissions) {
                     return Dataface_Error::permissionDenied(df_translate("Permission Denied for action no permissions", "Permission to perform action '" . $action['name'] . "' denied. " . "Requires permission " . $action['permission'] . " but you currently " . " have no permissions granted.", array('action' => $action)));
                 } else {
                     return Dataface_Error::permissionDenied(Dataface_LanguageTool::translate("Permission Denied for action.", "Permission to perform action '" . $action['name'] . "' denied.  \n                                                            Requires permission '" . $action['permission'] . "' but only granted '" . Dataface_PermissionsTool::namesAsString($permissions) . "'.", array('action' => $action, 'permissions_granted' => Dataface_PermissionsTool::namesAsString($permissions))));
                 }
             }
             if (method_exists($handler, 'handle')) {
                 $result = $handler->handle($doParams);
                 if (PEAR::isError($result) and $result->getCode() === DATAFACE_E_REQUEST_NOT_HANDLED) {
                     continue;
                 }
                 return $result;
             }
         }
     }
     throw new Exception(df_translate('scripts.Dataface.Application.handleRequest.NO_HANDLER_FOUND', "No handler found for request.  This should never happen because, at the very least, the default handler at dataface/actions/default.php should be called.  Check the permissions on dataface/actions/default.php to make sure that it is readable by the web server."), E_USER_ERROR);
 }