function drawUrl( $cbUri, &$sourceElem, &$data, $id, $htmlspecialchars = true, $inPage = true ) { global $_CB_framework; $ui = $_CB_framework->getUi(); if ( substr( $cbUri, 0, 4 ) == 'cbo:' ) { $subTaskValue = substr( $cbUri, 4 ); switch ( $subTaskValue ) { case 'newrow': $id = 0; // fallthrough: no break on purpose. case 'rowedit': //TBD this is duplicate of below $baseUrl = 'index.php'; $baseUrl .= '?option=' . $this->_options['option'] . '&task=' . $this->_options['task'] . '&cid=' . $this->_options['pluginid']; $url = $baseUrl . '&table=' . $this->_tableBrowserModel->attributes( 'name' ) . '&action=editrow'; // below: . '&tid=' . $id; break; case 'saveorder': case 'editrows': case 'deleterows': case 'copyrows': case 'updaterows': case 'publish': case 'unpublish': case 'enable': case 'disable': default: $url = 'javascript:cbDoListTask(this, ' // cb //TBD: this is duplicate of pager. . "'" . $this->taskName( false ). "','" // task . $this->subtaskName( false ). "','" // subtaskName . $this->subtaskValue( $subTaskValue, false ) . "','" // subtaskValue . $this->fieldId( 'id', null, false ) . "'" // fldName . ");"; break; } } elseif ( substr( $cbUri, 0, 10 ) == 'cb_action:' ) { $actionName = substr( $cbUri, 10 ); $action =& $this->_actions->getChildByNameAttr( 'action', 'name', $actionName ); if ( $action ) { $requestNames = explode( ' ', $action->attributes( 'request' ) ); $requestValues = explode( ' ', $action->attributes( 'action' ) ); $parametersValues = explode( ' ', $action->attributes( 'parameters' ) ); $baseUrl = 'index.php'; $baseUrl .= '?'; $baseRequests = array( 'option' => 'option', 'task' => 'task', 'cid' => 'pluginid' ); $urlParams = array(); foreach ( $baseRequests as $breq => $breqOptionsValue ) { if ( ( ! ( in_array( $breq, $requestNames ) || in_array( $breq, $parametersValues ) ) ) && isset( $this->_options[$breqOptionsValue] ) ) { $urlParams[$breq] = $breq . '=' . $this->_options[$breqOptionsValue]; } } $url = $baseUrl; for ( $i = 0, $n = count( $requestNames ); $i < $n; $i++ ) { $urlParams[$requestNames[$i]] = $requestNames[$i] . '=' . $requestValues[$i]; // other parameters = paramvalues added below } $url = $baseUrl . implode( '&', $urlParams ); } else { $url = "#action_not_defined:" . $actionName; } } else { $url = $cbUri; } if ( ! cbStartOfStringMatch( $url, 'javascript:' ) ) { // get the parameters of action/link from XML : $parametersNames = explode( ' ', $sourceElem->attributes( 'parameters' ) ); $parametersValues = explode( ' ', $sourceElem->attributes( 'paramvalues' ) ); $parametersValuesTypes = explode( ' ', $sourceElem->attributes( 'paramvaluestypes' ) ); // add currently activated filters to the parameters: if ( count( $this->_filters ) > 0 ) { foreach ( $this->_filters as $k => $v ) { $filterName = $this->fieldName( $k ); if ( ( $v['value'] != $v['default'] ) && ( ! in_array( $filterName, $parametersNames ) ) ) { $parametersNames[] = $filterName; $parametersValues[] = "'" . $v['value'] . "'"; //TBD: check this. } } } // add current search string, if any: $searchName = $this->fieldName( 'search' ); $searchValue = $this->fieldValue( 'search' ); if ( $searchValue && ( ! in_array( $searchName, $parametersNames ) ) ) { $parametersNames[] = $searchName; $parametersValues[] = "'" . $searchValue . "'"; } // generate current action (and parameters ?) as cbprevstate $cbprevstate = array(); foreach ( $this->_options as $req => $act ) { if ( $req && $act && ! in_array( $req, array( 'cbprevstate' ) ) ) { $cbprevstate[] = $req . '=' . $act; } } $parametersNames[] = 'cbprevstate'; $parametersValues[] = "'" . base64_encode( implode( '&', $cbprevstate ) ) . "'"; // finally generate URL: for ( $i = 0, $n = count( $parametersNames ); $i < $n; $i++ ) { $nameOfVariable = $parametersValues[$i]; if ( $nameOfVariable ) { if ( isset( $parametersValuesTypes[$i] ) && $parametersValuesTypes[$i] ) { if ( $parametersValuesTypes[$i] == 'sql:field' ) { $nameOfVariable = $data->$nameOfVariable; } else { // $nameOfVariable untouched } } elseif ( ( substr( $nameOfVariable, 0, 1 ) == "'" ) && ( substr( $nameOfVariable, -1 ) == "'" ) ) { $nameOfVariable = substr( $nameOfVariable, 1, -1 ); } else { $nameOfVariable = $data->$nameOfVariable; } $url .= '&' . $parametersNames[$i] . '=' . urlencode( $nameOfVariable ); } } if ( $ui == 2 ) { $url = $_CB_framework->backendUrl( $url, $htmlspecialchars, ( $inPage ? 'html' : 'component' ) ); } else { $url = cbSef( $url, $htmlspecialchars, ( $inPage ? 'html' : 'component' ) ); } } elseif ( $htmlspecialchars ) { $url = htmlspecialchars( $url ); } return $url; }
/** * Returns array of column names (pre/post/fixed with $colNamePrefix) of $table * * @param CBSimpleXMLElement $db * @param string $colNamePrefix Prefix to add to all column names * @return array|boolean False if not found */ function getMainTableColumnsNames(&$db, $colNamePrefix = '') { $table =& $db->getChildByNameAttr('table', 'maintable', 'true'); if ($table !== false) { $columns =& $table->getElementByPath('columns'); if ($columns !== false) { $columnNamesArray = array(); foreach ($columns->children() as $column) { if ($column->name() == 'column') { $columnNamesArray[] = $this->_prefixedName($column, $colNamePrefix); } } return $columnNamesArray; } } return false; }