本文整理汇总了PHP中Sintattica\Atk\Core\Tools::partial_url方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::partial_url方法的具体用法?PHP Tools::partial_url怎么用?PHP Tools::partial_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sintattica\Atk\Core\Tools
的用法示例。
在下文中一共展示了Tools::partial_url方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerChangeHandler
/**
* Register change handler.
*
* @param string $mode
* @param string $prefix
*/
protected function registerChangeHandler($mode, $prefix)
{
$mode = $mode == 'add' ? 'add' : 'edit';
$url = addslashes(Tools::partial_url($this->m_shuttle->m_ownerInstance->atkNodeUri(), $mode, 'attribute.' . $this->m_shuttle->getHtmlId($prefix) . '.filter', array('atkfieldprefix' => $prefix)));
$page = $this->m_shuttle->m_ownerInstance->getPage();
$page->register_scriptcode('function ' . $this->getChangeHandlerName($prefix) . "(el)\n {\n shuttle_refresh('" . $url . "', '" . $this->m_shuttle->getHtmlId($prefix) . '[cselected][][' . $this->m_shuttle->getRemoteKey() . ']' . "', '" . $prefix . $this->m_shuttle->fieldName() . "[section]', '" . $this->m_section . "')\n }\n");
}
示例2: doInit
/**
* This function shows a form to configure the .csv.
*/
public function doInit()
{
$content = $this->_getInitHtml();
$page = $this->getPage();
$page->register_scriptcode("\n function toggleSelectionName( fieldval )\n {\n if( fieldval == undefined )\n {\n fieldval = \$( 'export_selection_options' ).value;\n }\n new Ajax.Updater('export_attributes', '" . Tools::partial_url($this->m_postvars['atknodeuri'], 'export', 'export') . "exportvalue='+fieldval+'&' );\n\n if( fieldval != 'none' )\n {\n if( fieldval != 'new' )\n {\n new Ajax.Updater('selection_interact', '" . Tools::partial_url($this->m_postvars['atknodeuri'], 'export', 'selection_interact') . "exportvalue='+fieldval+'&' );\n new Ajax.Updater('export_name', '" . Tools::partial_url($this->m_postvars['atknodeuri'], 'export', 'selection_name') . "exportvalue='+fieldval+'&' );\n \$( 'selection_interact' ).style.display='';\n \$( 'export_name' ).style.display='';\n \$( 'export_save_button' ).style.display='';\n }\n else\n {\n \$( 'selection_interact' ).style.display='none';\n \$( 'export_name' ).style.display='';\n \$( 'export_selection_name' ).value='';\n \$( 'export_selection_options' ).selectedIndex=0;\n \$( 'export_save_button' ).style.display='none';\n }\n }\n else\n {\n \$( 'export_name' ).style.display='none';\n \$( 'selection_interact' ).style.display='none';\n \$( 'export_save_button' ).style.display='none';\n \$( 'export_selection_name' ).value='';\n }\n }");
$page->register_scriptcode("\n function confirm_delete()\n {\n var where_to = confirm('" . Tools::atktext('confirm_delete') . "');\n var dodelete = \$( 'export_selection_options' ).value;\n\n if (where_to == true)\n {\n window.location= \"" . Tools::dispatch_url($this->m_postvars['atknodeuri'], 'export', array('confirmed' => 'true')) . '&dodelete="+dodelete;
}
}');
$params = [];
$params['title'] = $this->m_node->actionTitle('export');
$params['content'] = $content;
$content = $this->getUi()->renderBox($params);
$output = $this->m_node->renderActionPage('export', $content);
$page->addContent($output);
return true;
}
示例3: edit
public function edit($record, $fieldprefix, $mode)
{
$this->getOwnerInstance()->getPage()->register_script(Config::getGlobal('assets_url') . 'javascript/class.atkradiodetailsattribute.js');
$name = $this->getHtmlName($fieldprefix);
$result = '<div class="atkradiodetailsattribute-selection">';
foreach ($this->m_options as $label => $value) {
$isSelected = $record[$this->fieldName()] == $value;
$checked = $isSelected ? ' checked="checked"' : '';
$attrNames = @$this->m_details[$value];
if ($attrNames != null) {
$url = Tools::partial_url($this->getOwnerInstance()->atkNodeUri(), $mode, 'attribute.' . $this->fieldName() . '.details', array('value' => $value, 'fieldprefix' => $fieldprefix));
$onChange = "ATK.RadioDetailsAttribute.select(this, '{$url}');";
} else {
$onChange = 'ATK.RadioDetailsAttribute.select(this);';
}
$result .= '
<input type="radio" class="atkradiodetailsattribute-option" name="' . $name . '" id="' . $name . '_' . $value . '" value="' . $value . '" onchange="' . $onChange . '"' . $checked . '/>
<label for="' . $name . '_' . $value . '">' . $this->text($label) . '</label><br/>
';
if ($attrNames != null) {
$result .= '<div id="' . $name . '_' . $value . '_details" class="atkradiodetailsattribute-details">';
if ($isSelected) {
foreach ($attrNames as $attrName) {
$attr = $this->getOwnerInstance()->getAttribute($attrName);
if (is_null($attr)) {
continue;
}
$result .= '<blockquote>' . $attr->edit($record, $fieldprefix, $mode) . ' ' . htmlentities($attr->getLabel($record, $mode)) . '</blockquote>';
}
}
$result .= '</div>';
}
}
$result .= '</div>';
return $result;
}
示例4: createGrid
/**
* Create the datagrid for the edit and display actions. The datagrid is
* configured with the correct node filter, excludes etc.
*
* The datagrid uses for both the edit and display actions the partial_grid
* method to update it's view.
*
* @param array $record the record
* @param string $mode the mode
* @param string $action the action
* @param bool $useSession use session?
*
* @return DataGrid grid
*/
protected function createGrid($record, $mode, $action, $useSession = true)
{
$this->createDestination();
$grid = DataGrid::create($this->m_destInstance, str_replace('.', '_', $this->getOwnerInstance()->atkNodeUri()) . '_' . $this->fieldName() . '_grid', null, true, $useSession);
$grid->setMode($mode);
$grid->setMasterNode($this->getOwnerInstance());
$grid->setMasterRecord($record);
$grid->removeFlag(DataGrid::EXTENDED_SEARCH);
if ($action == 'view') {
$grid->removeFlag(DataGrid::MULTI_RECORD_ACTIONS);
$grid->removeFlag(DataGrid::MULTI_RECORD_PRIORITY_ACTIONS);
}
$grid->setBaseUrl(Tools::partial_url($this->getOwnerInstance()->atkNodeUri(), $action, 'attribute.' . $this->fieldName() . '.grid'));
$grid->setExcludes($this->getGridExcludes());
$grid->addFilter($this->_getLoadWhereClause($record));
if ($this->m_destinationFilter != '') {
$grid->addFilter($this->parseFilter($this->m_destinationFilter, $record));
}
$this->modifyDataGrid($grid, DataGrid::CREATE);
return $grid;
}
示例5: drawAutoCompleteBox
/**
* Draw the auto-complete box.
*
* @param array $record The record
* @param string $fieldprefix The fieldprefix
* @param string $mode The mode we're in
* @return string html
*/
public function drawAutoCompleteBox($record, $fieldprefix, $mode)
{
$this->createDestination();
$page = $this->m_ownerInstance->getPage();
$page->register_script(Config::getGlobal('assets_url') . 'javascript/class.atkmanytoonerelation.js');
$id = $this->getHtmlId($fieldprefix);
$name = $this->getHtmlName($fieldprefix);
$result = '';
$label = '';
$value = '';
$options = [];
$selValues = [];
$currentValue = null;
$hasNullOption = false;
$noneLabel = '';
$emptyValue = '';
$htmlAttributes = [];
// validate is this is a selectable record and if so retrieve the display label and hidden value
if ($this->_isSelectableRecord($record, $mode)) {
$currentValue = $record[$this->fieldName()];
$label = $this->m_destInstance->descriptor($record[$this->fieldName()]);
$value = $this->m_destInstance->primaryKey($record[$this->fieldName()]);
}
// create the widget
if ($this->hasFlag(self::AF_MANYTOONE_OBLIGATORY_NULL_ITEM) || !$this->hasFlag(self::AF_OBLIGATORY) && !$this->hasFlag(self::AF_RELATION_NO_NULL_ITEM) || Config::getGlobal('list_obligatory_null_item') && !is_array($value)) {
$hasNullOption = true;
$noneLabel = $this->getNoneLabel($mode);
$options[$emptyValue] = $noneLabel;
}
if ($currentValue) {
$options[$value] = $label;
$selValues[] = $value;
}
$selectOptions = [];
$selectOptions['enable-select2'] = true;
$selectOptions['enable-manytoonereleation-autocomplete'] = true;
$selectOptions['dropdown-auto-width'] = false;
$selectOptions['ajax--url'] = Tools::partial_url($this->m_ownerInstance->atkNodeUri(), $mode, 'attribute.' . $this->fieldName() . '.autocomplete');
$selectOptions['minimum-input-length'] = $this->m_autocomplete_minchars;
// standard select2 with clear button
if ($hasNullOption) {
$selectOptions['allow-clear'] = true;
$selectOptions['placeholder'] = $noneLabel;
}
if (!empty($this->getWidth())) {
$selectOptions['width'] = $this->getWidth();
} else {
$selectOptions['width'] = 'auto';
}
$selectOptions = array_merge($selectOptions, $this->m_select2Options['edit']);
if (count($this->m_onchangecode)) {
$htmlAttributes['onchange'] = $this->getHtmlId($fieldprefix) . '_onChange(this)';
$this->_renderChangeHandler($fieldprefix);
}
$result .= $this->drawSelect($id, $name, $options, $selValues, $selectOptions, $htmlAttributes);
$result .= ' ' . $this->createSelectAndAutoLinks($name, $record);
return $result;
}
示例6: edit
/**
* Returns a piece of html code that can be used in a form to edit this
* attribute's value.
*
* @param array $record The record that holds the value for this attribute.
* @param string $fieldprefix The fieldprefix to put in front of the name
* of any html form element for this attribute.
* @param string $mode The mode we're in ('add' or 'edit')
*
* @return string A piece of htmlcode for editing this attribute
*/
public function edit($record, $fieldprefix, $mode)
{
// Add onchange handler
$mode = $mode == 'add' ?: 'edit';
$url = addslashes(Tools::partial_url($this->m_ownerInstance->atkNodeUri(), $mode, 'attribute.' . $this->getHtmlId($fieldprefix) . '.selection', array('atkfieldprefix' => $fieldprefix)));
$this->addOnChangeHandler("shuttle_refresh('{$url}', '" . $this->getHtmlId($fieldprefix) . '[cselected][][' . $this->getRemoteKey() . ']' . "', '" . $fieldprefix . $this->fieldName() . "[section]', el);");
$this->_renderChangeHandler($fieldprefix);
$filtersBySection = [];
foreach (array(ShuttleControl::AVAILABLE, ShuttleControl::SELECTED) as $section) {
foreach ($this->m_controlsBySection[$section] as $control) {
if (is_a($control, 'ShuttleFilter')) {
/** @var ShuttleFilter $control */
$filter = $control->getFilter($record);
if (!empty($filter)) {
$filtersBySection[$section][] = $filter;
}
$limit = $control->getLimit();
if ($limit !== null) {
$this->m_limit = $limit;
}
}
}
}
$availableFilter = '';
if (count($filtersBySection[ShuttleControl::AVAILABLE]) > 0) {
$availableFilter = '(' . implode(') AND (', $filtersBySection[ShuttleControl::AVAILABLE]) . ')';
}
$selectedFilter = '';
if (count($filtersBySection[ShuttleControl::SELECTED]) > 0) {
$selectedFilter = '(' . implode(') AND (', $filtersBySection[ShuttleControl::SELECTED]) . ')';
}
// Get controls for 'available' side
$ava_controls = [];
foreach ($this->m_controlsBySection[ShuttleControl::AVAILABLE] as $control) {
$ava_controls[] = $control->render($record, $mode, $fieldprefix);
}
// Get controls for 'selected' side
$sel_controls = [];
foreach ($this->m_controlsBySection[ShuttleControl::SELECTED] as $control) {
$sel_controls[] = $control->render($record, $mode, $fieldprefix);
}
// Get available records
$left = $this->hasFlag(self::AF_SHUTTLERELATION_NO_AUTOLOAD) ? [] : $this->getAvailableFields($record, $mode, $availableFilter);
$available_options = [];
for ($i = 0, $_i = count($left); $i < $_i; ++$i) {
$available_options[$left[$i][$this->m_destInstance->primaryKeyField()]] = $this->m_destInstance->descriptor($left[$i]);
}
// Get selected records
$right = $this->getSelectedFields($record, $mode, $selectedFilter, $availableFilter);
$selected_options = [];
for ($i = 0, $_i = count($right); $i < $_i; ++$i) {
$selected_options[$right[$i][$this->m_destInstance->primaryKeyField()]] = $this->m_destInstance->descriptor($right[$i]);
}
$leftname = $this->getHtmlId($fieldprefix) . '[available]';
$rightname = $this->getHtmlId($fieldprefix) . '[cselected][][' . $this->getRemoteKey() . ']';
$name = $this->getHtmlId($fieldprefix) . '[selected][][' . $this->getRemoteKey() . ']';
// Build jsonned value for selected fields
$vals = [];
foreach ($right as $fld) {
$vals[] = $fld[$this->m_destInstance->primaryKeyField()];
}
$value = Json::encode($vals);
if ($value == 'null') {
$value = '[]';
}
// on submit, we must select all items in the right selector, as unselected items will not be posted.
$page = $this->m_ownerInstance->getPage();
$page->register_script(Config::getGlobal('assets_url') . 'javascript/class.atkextendableshuttlerelation.js');
$page->register_submitscript("shuttle_selectAll('" . $rightname . "');");
$ui = Ui::getInstance();
$result = $ui->render('extendableshuttle.tpl', array('leftname' => $leftname, 'rightname' => $rightname, 'name' => $name, 'htmlid' => $this->getHtmlId($fieldprefix), 'remotekey' => $this->getRemoteKey(), 'value' => $value, 'ava_controls' => $ava_controls, 'sel_controls' => $sel_controls, 'available_options' => $available_options, 'selected_options' => $selected_options));
return $result;
}
示例7: initOnCreate
/**
* Initialize when we create the datagrid for the first time.
*/
protected function initOnCreate()
{
$this->setFlags($this->convertNodeFlags($this->getNode()->getFlags()));
$this->setBaseUrl(Tools::partial_url($this->getNode()->atkNodeUri(), $this->getNode()->m_action, 'datagrid'));
$this->setDefaultLimit(Config::getGlobal('recordsperpage'));
$this->setDefaultActions($this->getNode()->defaultActions('admin'));
$this->setDefaultOrderBy($this->getNode()->getOrder());
$this->setTemplate('datagrid.tpl');
$this->setActionSessionStatus(SessionManager::SESSION_NESTED);
$this->setMode('admin');
$this->setMRASelectionMode($this->getNode()->getMRASelectionMode());
if (!$this->getNode()->hasFlag(Node::NF_NO_FILTER)) {
foreach ($this->getNode()->m_filters as $key => $value) {
$this->addFilter($key . "='" . $value . "'");
}
foreach ($this->getNode()->m_fuzzyFilters as $filter) {
$parser = new StringParser($filter);
$filter = $parser->parse(array('table' => $this->getNode()->getTable()));
$this->addFilter($filter);
}
}
$this->addComponent('list', __NAMESPACE__ . '\\DataGridList');
$this->addComponent('summary', __NAMESPACE__ . '\\DataGridSummary');
$this->addComponent('limit', __NAMESPACE__ . '\\DataGridLimit', array('showAll' => Config::getGlobal('enable_showall')));
$this->addComponent('norecordsfound', __NAMESPACE__ . '\\DataGridNoRecordsFound');
$this->addComponent('paginator', __NAMESPACE__ . '\\DataGridPaginator');
if (!empty($this->getNode()->m_index)) {
$this->addComponent('index', 'atk.datagrid.atkdgindex');
}
if (count($this->getNode()->m_editableListAttributes) > 0) {
$this->addComponent('editcontrol', __NAMESPACE__ . '\\DataGridEditControl');
}
}
示例8: initDependencies
/**
* Initialize and calls the dependencies.
*
* @param array $record record
* @param string $fieldPrefix the prefix for this attribute in an HTML form
* @param string $mode add/edit mode
* @param bool $noCall only initialize dependencies, without calling them
*/
public function initDependencies(&$record, $fieldPrefix, $mode, $noCall = false)
{
if (count($this->getDependencies()) == 0) {
return;
}
if (!$noCall) {
$this->_callDependencies($record, $fieldPrefix, $mode, true);
}
$action = $this->getOwnerInstance()->m_action;
if ($action == null) {
$action = $mode == 'add' ? 'add' : 'edit';
}
$url = Tools::partial_url($this->getOwnerInstance()->atkNodeUri(), $action, 'attribute.' . $this->fieldName() . '.dependencies', array('atkdata' => array('fieldPrefix' => $fieldPrefix, 'mode' => $mode)));
$url = Json::encode($url);
$this->getOwnerInstance()->getPage()->register_script(Config::getGlobal('assets_url') . 'javascript/class.atkattribute.js');
$code = "ATK.Attribute.callDependencies({$url}, el);";
$this->addOnChangeHandler($code);
}
示例9: getSectionControl
/**
* Create the clickable label for the section.
*
* @param array $field
* @param string $mode
*
* @return string Html
*/
public function getSectionControl($field, $mode)
{
// label
$label = self::getSectionLabel($this->m_node, $field['name']);
// our name
list($tab, $section) = explode('.', $field['name']);
$name = "section_{$tab}_{$section}";
$url = Tools::partial_url($this->m_node->atkNodeUri(), $mode, 'sectionstate', array('atksectionname' => $name));
// create onclick statement.
$onClick = " onClick=\"javascript:handleSectionToggle(this,null,'{$url}'); return false;\"";
$initClass = 'openedSection';
//if the section is not active, we close it on load.
$default = in_array($field['name'], $this->m_node->getActiveSections($tab, $mode)) ? 'opened' : 'closed';
$sectionstate = State::get(array('nodetype' => $this->m_node->atkNodeUri(), 'section' => $name), $default);
if ($sectionstate == 'closed') {
$initClass = 'closedSection';
$page = $this->getPage();
$page->register_scriptcode("addClosedSection('{$name}');");
}
// create the clickable link
return '<span class="atksectionwr"><a href="javascript:void(0)" id="' . $name . '" class="atksection ' . $initClass . '"' . $onClick . '>' . $label . '</a></span>';
}
示例10: renderAdditionField
/**
* Render addition field.
*
* @param array $record
* @param string $fieldprefix field prefix
* @param string $mode
*
* @return string
*/
protected function renderAdditionField($record, $fieldprefix, $mode)
{
if ($this->getLink()->hasFlag(Node::NF_NO_ADD)) {
return '';
}
$url = Tools::partial_url($this->getOwnerInstance()->atkNodeUri(), $mode, 'attribute.' . $this->fieldName() . '.selectedrecord', array('fieldprefix' => $fieldprefix));
$relation = $this->getManyToOneRelation();
$hasPositionAttribute = $this->hasPositionAttribute() ? 'true' : 'false';
$relation->addOnChangeHandler("ATK.ManyToManySelectRelation.add(el, '{$url}', {$hasPositionAttribute});");
$relation->setNoneLabel($this->text('select_none_obligatory'));
$result = $relation->edit($record, $fieldprefix, $mode);
if ($result == $this->text('select_none_obligatory')) {
$result = '';
}
return $result;
}