本文整理汇总了PHP中MenusHelper::getLinkKey方法的典型用法代码示例。如果您正苦于以下问题:PHP MenusHelper::getLinkKey方法的具体用法?PHP MenusHelper::getLinkKey怎么用?PHP MenusHelper::getLinkKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenusHelper
的用法示例。
在下文中一共展示了MenusHelper::getLinkKey方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
// Initialise variables.
$html = array();
$recordId = (int) $this->form->getValue('id');
$size = ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
$class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"';
// Get a reverse lookup of the base link URL to Title
$model = JModel::getInstance('menutypes', 'menusModel');
$rlu = $model->getReverseLookup();
switch ($this->value) {
case 'url':
$value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
break;
case 'alias':
$value = JText::_('COM_MENUS_TYPE_ALIAS');
break;
case 'separator':
$value = JText::_('COM_MENUS_TYPE_SEPARATOR');
break;
default:
$link = $this->form->getValue('link');
// Clean the link back to the option, view and layout
$value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link)));
break;
}
// Load the javascript and css
JHtml::_('behavior.framework');
JHtml::_('behavior.modal');
$html[] = '<input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />';
$html[] = '<input type="button" value="' . JText::_('JSELECT') . '" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId) . '\'})" />';
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
return implode("\n", $html);
}
示例2: getTypeOptions
/**
* Method to get the available menu item type options.
*
* @return array Array of groups with menu item types.
* @since 1.6
*/
public function getTypeOptions()
{
jimport('joomla.filesystem.file');
// Initialise variables.
$lang = JFactory::getLanguage();
$list = array();
// Get the list of components.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('name, element AS ' . $db->qn('option'));
$query->from('#__extensions');
$query->where('type = ' . $db->q('component'));
$query->where('enabled = 1');
$query->order('name ASC');
$db->setQuery($query);
$components = $db->loadObjectList();
foreach ($components as $component) {
if ($options = $this->getTypeOptionsByComponent($component->option)) {
$list[$component->name] = $options;
// Create the reverse lookup for link-to-name.
foreach ($options as $option) {
if (isset($option->request)) {
$this->rlu[MenusHelper::getLinkKey($option->request)] = $option->get('title');
if (isset($option->request['option'])) {
$lang->load($option->request['option'] . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($option->request['option'] . '.sys', JPATH_ADMINISTRATOR . '/components/' . $option->request['option'], null, false, false) || $lang->load($option->request['option'] . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($option->request['option'] . '.sys', JPATH_ADMINISTRATOR . '/components/' . $option->request['option'], $lang->getDefault(), false, false);
}
}
}
}
}
return $list;
}
示例3: getTypeOptions
/**
* Method to get the available menu item type options.
*
* @return array Array of groups with menu item types.
* @since 1.6
*/
public function getTypeOptions()
{
// Initialise variables.
$lang = Lang::getRoot();
$list = array();
// Get the list of components.
$db = App::get('db');
$query = $db->getQuery(true);
$query->select('name, element AS ' . $db->qn('option'));
$query->from('#__extensions');
$query->where('type = ' . $db->q('component'));
$query->where('enabled = 1');
$query->order('name ASC');
$db->setQuery($query);
$components = $db->loadObjectList();
foreach ($components as $component) {
if ($options = $this->getTypeOptionsByComponent($component->option)) {
$list[$component->name] = $options;
// Create the reverse lookup for link-to-name.
foreach ($options as $option) {
if (isset($option->request)) {
$this->rlu[MenusHelper::getLinkKey($option->request)] = $option->get('title');
if (isset($option->request['option'])) {
$lang->load($option->request['option'] . '.sys', PATH_APP, null, false, true) || $lang->load($option->request['option'] . '.sys', PATH_CORE . '/components/' . $option->request['option'] . '/admin', null, false, true);
}
}
}
}
}
return $list;
}
示例4: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$html = array();
$recordId = (int) $this->form->getValue('id');
$size = ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
$class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"';
$required = ($v = $this->element['required']) ? ' required="required"' : '';
// Get a reverse lookup of the base link URL to Title
$model = JModelLegacy::getInstance('menutypes', 'menusModel');
$rlu = $model->getReverseLookup();
switch ($this->value) {
case 'url':
$value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
break;
case 'alias':
$value = JText::_('COM_MENUS_TYPE_ALIAS');
break;
case 'separator':
$value = JText::_('COM_MENUS_TYPE_SEPARATOR');
break;
case 'heading':
$value = JText::_('COM_MENUS_TYPE_HEADING');
break;
default:
$link = $this->form->getValue('link');
// Clean the link back to the option, view and layout
$value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link)));
break;
}
// Include jQuery
JHtml::_('jquery.framework');
// Add the script to the document head.
JFactory::getDocument()->addScriptDeclaration('
function jSelectPosition_' . $this->id . '(name) {
document.getElementById("' . $this->id . '").value = name;
}
');
$link = JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId);
$html[] = '<span class="input-append"><input type="text" ' . $required . ' readonly="readonly" id="' . $this->id . '" value="' . $value . '"' . $size . $class . ' />';
$html[] = '<a href="#menuTypeModal" role="button" class="btn btn-primary" data-toggle="modal" title="' . JText::_('JSELECT') . '">' . '<span class="icon-list icon-white"></span> ' . JText::_('JSELECT') . '</a></span>';
$html[] = JHtml::_('bootstrap.renderModal', 'menuTypeModal', array('url' => $link, 'title' => JText::_('COM_MENUS_ITEM_FIELD_TYPE_LABEL'), 'width' => '800px', 'height' => '300px', 'footer' => '<button class="btn" data-dismiss="modal" aria-hidden="true">' . JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '</button>'));
$html[] = '<input class="input-small" type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
return implode("\n", $html);
}
示例5: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
// Initialise variables.
$html = array();
$recordId = (int) $this->form->getValue('id');
$size = ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
$class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"';
// Get a reverse lookup of the base link URL to Title
$model = JModelLegacy::getInstance('menutypes', 'menusModel');
$rlu = $model->getReverseLookup();
switch ($this->value) {
case 'url':
$value = Lang::txt('COM_MENUS_TYPE_EXTERNAL_URL');
break;
case 'alias':
$value = Lang::txt('COM_MENUS_TYPE_ALIAS');
break;
case 'separator':
$value = Lang::txt('COM_MENUS_TYPE_SEPARATOR');
break;
default:
$link = $this->form->getValue('link');
// Clean the link back to the option, view and layout
$value = Lang::txt(\Hubzero\Utility\Arr::getValue($rlu, MenusHelper::getLinkKey($link)));
break;
}
// Load the javascript and css
Html::behavior('framework');
Html::behavior('modal');
Document::addScriptDeclaration("\n\t\t\tjQuery(document).ready(function(\$){\n\t\t\t\t\$('input.modal').fancybox({\n\t\t\t\t\tarrows: false,\n\t\t\t\t\ttype: 'iframe',\n\t\t\t\t\tautoSize: false,\n\t\t\t\t\tfitToView: false,\n\t\t\t\t\twidth: 600,\n\t\t\t\t\theight: 450,\n\t\t\t\t\thref: '" . Route::url('index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId, false) . "'\n\t\t\t\t});\n\t\t\t});\n\t\t");
$html[] = '<div class="input-modal">';
$html[] = '<span class="input-cell">';
$html[] = '<input type="text" id="' . $this->id . '" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />';
$html[] = '</span><span class="input-cell">';
$html[] = '<input type="button" class="modal" value="' . Lang::txt('JSELECT') . '" />';
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
$html[] = '</span>';
$html[] = '</div>';
return implode("\n", $html);
}
示例6: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$html = array();
$recordId = (int) $this->form->getValue('id');
$size = ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
$class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"';
$required = ($v = $this->element['required']) ? ' required="required"' : '';
// Get a reverse lookup of the base link URL to Title
$model = JModelLegacy::getInstance('menutypes', 'menusModel');
$rlu = $model->getReverseLookup();
switch ($this->value) {
case 'url':
$value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
break;
case 'alias':
$value = JText::_('COM_MENUS_TYPE_ALIAS');
break;
case 'separator':
$value = JText::_('COM_MENUS_TYPE_SEPARATOR');
break;
case 'heading':
$value = JText::_('COM_MENUS_TYPE_HEADING');
break;
default:
$link = $this->form->getValue('link');
// Clean the link back to the option, view and layout
$value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link)));
break;
}
// Load the javascript and css
JHtml::_('behavior.framework');
JHtml::_('behavior.modal');
$getMenuTypesUrl = 'index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId;
$html[] = '<span class="input-append">' . '<input type="text" ' . $required . ' readonly="readonly" id="' . $this->id . '" value="' . $value . '"' . $size . $class . ' />' . '<a class="btn btn-primary" ' . 'onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . JRoute::_($getMenuTypesUrl) . '\'})">' . '<i class="icon-list icon-white"></i> ' . JText::_('JSELECT') . '</a></span>';
$html[] = '<input class="input-small" type="hidden" name="' . $this->name . '" ' . 'value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
return implode("\n", $html);
}
示例7: _getTypeOptions
/**
* Method to get the available menu item type options.
*
* @return array Array of groups with menu item types.
* @since 1.6
*/
protected function _getTypeOptions()
{
jimport('joomla.filesystem.file');
// Initialise variables.
$lang =& JFactory::getLanguage();
$list = array();
// Get the list of components.
$db =& JFactory::getDBO();
$db->setQuery('SELECT `name`, `element` AS "option"' . ' FROM `#__extensions`' . ' WHERE `type` = "component"' . ' AND `enabled` = 1' . ' ORDER BY `name`');
$components = $db->loadObjectList();
foreach ($components as $component) {
if ($options = $this->_getTypeOptionsByComponent($component->option)) {
$list[$component->name] = $options;
// Create the reverse lookup for link-to-name.
foreach ($options as $option) {
if (isset($option->request)) {
$this->_rlu[MenusHelper::getLinkKey($option->request)] = $option->get('title');
if (isset($option->request['option'])) {
$lang->load($option->request['option'] . '.menu', JPATH_ADMINISTRATOR . '/components/' . $option->request['option']);
$lang->load($option->request['option'] . '.menu');
}
}
}
}
}
return $list;
}
示例8: getItem
/**
* Method to get a menu item.
*
* @param integer $pk An optional id of the object to get, otherwise the id from the model state is used.
*
* @return mixed Menu item data object on success, false on failure.
* @since 1.6
*/
public function getItem($pk = null)
{
// Initialise variables.
$pk = !empty($pk) ? $pk : (int) $this->getState('item.id');
// Get a level row instance.
$table = $this->getTable();
// Attempt to load the row.
$table->load($pk);
// Check for a table object error.
if ($error = $table->getError()) {
$this->setError($error);
$false = false;
return $false;
}
// Prime required properties.
if ($type = $this->getState('item.type')) {
$table->type = $type;
}
if (empty($table->id)) {
$table->parent_id = $this->getState('item.parent_id');
$table->menutype = $this->getState('item.menutype');
$table->params = '{}';
}
// If the link has been set in the state, possibly changing link type.
if ($link = $this->getState('item.link')) {
// Check if we are changing away from the actual link type.
if (MenusHelper::getLinkKey($table->link) != MenusHelper::getLinkKey($link)) {
$table->link = $link;
}
}
switch ($table->type) {
case 'alias':
$table->component_id = 0;
$args = array();
parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
break;
case 'separator':
$table->link = '';
$table->component_id = 0;
break;
case 'url':
$table->component_id = 0;
parse_str(parse_url($table->link, PHP_URL_QUERY));
break;
case 'component':
default:
// Enforce a valid type.
$table->type = 'component';
// Ensure the integrity of the component_id field is maintained, particularly when changing the menu item type.
$args = array();
parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
if (isset($args['option'])) {
// Load the language file for the component.
$lang = JFactory::getLanguage();
$lang->load($args['option'], JPATH_ADMINISTRATOR, null, false, false) || $lang->load($args['option'], JPATH_ADMINISTRATOR . '/components/' . $args['option'], null, false, false) || $lang->load($args['option'], JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($args['option'], JPATH_ADMINISTRATOR . '/components/' . $args['option'], $lang->getDefault(), false, false);
// Determine the component id.
$component = JComponentHelper::getComponent($args['option']);
if (isset($component->id)) {
$table->component_id = $component->id;
}
}
break;
}
// We have a valid type, inject it into the state for forms to use.
$this->setState('item.type', $table->type);
// Convert to the JObject before adding the params.
$properties = $table->getProperties(1);
$result = JArrayHelper::toObject($properties, 'JObject');
// Convert the params field to an array.
$registry = new JRegistry();
$registry->loadJSON($table->params);
$result->params = $registry->toArray();
// Merge the request arguments in to the params for a component.
if ($table->type == 'component') {
// Note that all request arguments become reserved parameter names.
$result->request = $args;
$result->params = array_merge($result->params, $args);
}
if ($table->type == 'alias') {
// Note that all request arguments become reserved parameter names.
$args = array();
parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
$result->params = array_merge($result->params, $args);
}
if ($table->type == 'url') {
// Note that all request arguments become reserved parameter names.
$args = array();
parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
$result->params = array_merge($result->params, $args);
}
return $result;
}
示例9: getItem
/**
* Method to get a menu item.
*
* @param integer $pk An optional id of the object to get, otherwise the id from the model state is used.
*
* @return mixed Menu item data object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
$pk = !empty($pk) ? $pk : (int) $this->getState('item.id');
// Get a level row instance.
$table = $this->getTable();
// Attempt to load the row.
$table->load($pk);
// Check for a table object error.
if ($error = $table->getError()) {
$this->setError($error);
return false;
}
// Prime required properties.
if ($type = $this->getState('item.type')) {
$table->type = $type;
}
if (empty($table->id)) {
$table->parent_id = $this->getState('item.parent_id');
$table->menutype = $this->getState('item.menutype');
$table->params = '{}';
}
// If the link has been set in the state, possibly changing link type.
if ($link = $this->getState('item.link')) {
// Check if we are changing away from the actual link type.
if (MenusHelper::getLinkKey($table->link) != MenusHelper::getLinkKey($link)) {
$table->link = $link;
}
}
switch ($table->type) {
case 'alias':
$table->component_id = 0;
$args = array();
parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
break;
case 'separator':
case 'heading':
$table->link = '';
$table->component_id = 0;
break;
case 'url':
$table->component_id = 0;
$args = array();
parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
break;
case 'component':
default:
// Enforce a valid type.
$table->type = 'component';
// Ensure the integrity of the component_id field is maintained, particularly when changing the menu item type.
$args = array();
parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
if (isset($args['option'])) {
// Load the language file for the component.
$lang = JFactory::getLanguage();
$lang->load($args['option'], JPATH_ADMINISTRATOR, null, false, true) || $lang->load($args['option'], JPATH_ADMINISTRATOR . '/components/' . $args['option'], null, false, true);
// Determine the component id.
$component = JComponentHelper::getComponent($args['option']);
if (isset($component->id)) {
$table->component_id = $component->id;
}
}
break;
}
// We have a valid type, inject it into the state for forms to use.
$this->setState('item.type', $table->type);
// Convert to the JObject before adding the params.
$properties = $table->getProperties(1);
$result = JArrayHelper::toObject($properties);
// Convert the params field to an array.
$registry = new Registry();
$registry->loadString($table->params);
$result->params = $registry->toArray();
// Merge the request arguments in to the params for a component.
if ($table->type == 'component') {
// Note that all request arguments become reserved parameter names.
$result->request = $args;
$result->params = array_merge($result->params, $args);
// Special case for the Login menu item.
// Display the login or logout redirect URL fields if not empty
if ($table->link == 'index.php?option=com_users&view=login') {
if (!empty($result->params['login_redirect_url'])) {
$result->params['loginredirectchoice'] = '0';
}
if (!empty($result->params['logout_redirect_url'])) {
$result->params['logoutredirectchoice'] = '0';
}
}
}
if ($table->type == 'alias') {
// Note that all request arguments become reserved parameter names.
$result->params = array_merge($result->params, $args);
//.........这里部分代码省略.........
示例10: addReverseLookupUrl
/**
* Method to create the reverse lookup for link-to-name.
* (can be used from onAfterGetMenuTypeOptions handlers)
*
* @param $option JObject with request array or string and title public variables
*
* @return void
* @since 3.1
*/
public function addReverseLookupUrl($option)
{
$this->rlu[MenusHelper::getLinkKey($option->request)] = $option->get('title');
}