本文整理汇总了PHP中JArrayHelper::pivot方法的典型用法代码示例。如果您正苦于以下问题:PHP JArrayHelper::pivot方法的具体用法?PHP JArrayHelper::pivot怎么用?PHP JArrayHelper::pivot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JArrayHelper
的用法示例。
在下文中一共展示了JArrayHelper::pivot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($tpl = null)
{
// Load the helper(s)
$app = JFactory::getApplication();
if (!class_exists('VmHTML')) {
require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
}
$task = $app->input->getString('task', '');
$tsmart_product_id = $app->input->getInt('tsmart_product_id', 0);
$model = tmsModel::getModel();
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmproduct.php';
$this->tsmart_product_id = $app->input->get('tsmart_product_id', 0, 'int');
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmhotel.php';
$this->list_hotel = tsmHotel::get_list_hotel();
$this->list_hotel = JArrayHelper::pivot($this->list_hotel, 'tsmart_hotel_id');
$config = JFactory::getConfig();
$layoutName = vRequest::getCmd('layout', 'default');
if ($layoutName == 'edit') {
$cid = vRequest::getInt('cid');
$task = vRequest::getCmd('task', 'add');
if ($task != 'add' && !empty($cid) && !empty($cid[0])) {
$cid = (int) $cid[0];
} else {
$cid = 0;
}
$model->setId($cid);
$this->item = $model->getItem();
$this->SetViewTitle('', $this->item->title);
$this->addStandardEditViewCommandsPopup();
} else {
$this->item = $model->getItem();
$this->SetViewTitle();
$this->addStandardDefaultViewCommands();
$this->addStandardDefaultViewLists($model, 0, 'ASC');
$this->items = $model->getItemList(vRequest::getCmd('search', false));
$this->pagination = $model->getPagination();
if ($task == 'edit_item' || $task == 'add_new_item') {
$app = JFactory::getApplication();
$input = $app->input;
$tsmart_itinerary_id = $input->getInt('tsmart_itinerary_id', 0);
$tsmart_product_id = $input->getInt('tsmart_product_id', 0);
$cid = vRequest::getInt('cid');
$tsmart_accommodation_id = $cid[0];
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php';
$this->list_service_class = tsmserviceclass::get_list_service_class_by_tour_id($tsmart_product_id);
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmaccommodation.php';
$this->list_hotel_selected_by_service_class_id_and_itinerary_id = tsmaccommodation::get_list_hotel_selected_by_service_class_id_and_itinerary_id_accommodation_id($this->list_service_class, $tsmart_itinerary_id, $tsmart_accommodation_id);
}
}
parent::display($tpl);
}
示例2: defined
* @package External Login
* @subpackage Component
* @copyright Copyright (C) 2008-2014 Christophe Demko, Ioannis Barounis, Alexandre Gandois. All rights reserved.
* @author Christophe Demko
* @author Ioannis Barounis
* @author Alexandre Gandois
* @link http://www.chdemko.com
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
// No direct access to this file
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
$user = JFactory::getUser();
$ordering = $this->state->get('list.ordering') == 'a.ordering';
$plugins = JArrayHelper::pivot(ExternalloginHelper::getPlugins(), 'value');
if (!count($this->items)) {
?>
<tr class="row<?php
echo $i % 2;
?>
">
<td colspan="6" class="center">
<?php
echo JText::_('COM_EXTERNALLOGIN_NO_RECORDS');
?>
</td>
</tr>
<?php
} else {
foreach ($this->items as $i => $item) {
示例3: get_list_promotion_price
public function get_list_promotion_price()
{
$app = JFactory::getApplication();
$input = $app->input;
$view =& $this->getView('promotion', 'html', 'tsmartView');
$tsmart_promotion_price_id = $input->get('tsmart_promotion_price_id', 0, 'int');
$model_promotion_price = tmsModel::getModel('promotion');
$model_promotion_price->setId($tsmart_promotion_price_id);
$promotion_price = $model_promotion_price->get_promotion_price();
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmpromotion.php';
$product = vmpromotion::get_product_by_promotion_price_id($tsmart_promotion_price_id);
$tsmart_product_id = $product->tsmart_product_id;
$return_item = new stdClass();
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php';
$list_service_class = tsmserviceclass::get_list_service_class_by_tour_id($tsmart_product_id);
$return_item->list_service_class = $list_service_class;
$return_item->promotion_price = $promotion_price;
$view->assignRef('promotion_price', $return_item->promotion_price);
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmpromotion.php';
$model_product = tmsModel::getModel('product');
$product = $model_product->getItem($tsmart_product_id);
$return_item->tour = $product;
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmpromotion.php';
$product = vmpromotion::get_product_by_promotion_price_id($tsmart_promotion_price_id);
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php';
if ($product->price_type != tsmGroupSize::FLAT_PRICE) {
$return_item->list_tour_promotion_price_by_tour_promotion_price_id = vmpromotion::get_list_tour_promotion_price_by_tour_promotion_price_id($tsmart_promotion_price_id);
$view->assignRef('list_tour_promotion_price_by_tour_promotion_price_id', $return_item->list_tour_promotion_price_by_tour_promotion_price_id);
} else {
$return_item->tour_private_price_by_tour_promotion_price_id = vmpromotion::get_list_tour_promotion_price_by_tour_price_id_for_promotion_price($tsmart_promotion_price_id);
$view->assignRef('tour_private_price_by_tour_promotion_price_id', $return_item->tour_private_price_by_tour_promotion_price_id);
}
//get markup
$return_item->list_promotion_mark_up = vmpromotion::get_list_mark_up_by_tour_promotion_price_id($tsmart_promotion_price_id);
$return_item->list_promotion_mark_up = is_array($return_item->list_promotion_mark_up) ? $return_item->list_promotion_mark_up : array($return_item->list_promotion_mark_up);
$return_item->list_promotion_mark_up = JArrayHelper::pivot($return_item->list_promotion_mark_up, 'type');
$view->assignRef('list_promotion_mark_up', $return_item->list_promotion_mark_up);
//end get markup
//get markup
$return_item->list_promotion = vmpromotion::get_list_promotion_by_tour_promotion_price_id($tsmart_promotion_price_id);
$return_item->list_promotion = is_array($return_item->list_promotion) ? $return_item->list_promotion : array($return_item->list_promotion);
$return_item->list_promotion = JArrayHelper::pivot($return_item->list_promotion, 'type');
$view->assignRef('list_promotion', $return_item->list_promotion);
//end get markup
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php';
$return_item->list_group_size_by_tour_id = vmpromotion::get_list_group_size_by_tour_id($tsmart_product_id);
$view->assignRef('list_group_size_by_tour_id', $return_item->list_group_size_by_tour_id);
ob_start();
$input->set('tpl', 'price');
$view->assignRef('product', $product);
$view->display_price();
$price_content = ob_get_contents();
$return_item->price_content = $price_content;
ob_end_clean();
// get the callback function
echo json_encode($return_item);
die;
}
示例4: testPivot
/**
* Tests the JArrayHelper::pivot method.
*
* @param array $source The source array.
* @param string $key Where the elements of the source array are objects or arrays, the key to pivot on.
* @param array $expected The expected result.
*
* @return void
*
* @dataProvider getTestPivotData
* @covers JArrayHelper::pivot
* @since 11.3
*/
public function testPivot($source, $key, $expected)
{
$this->assertThat(
JArrayHelper::pivot($source, $key),
$this->equalTo($expected)
);
}
示例5: getFieldsByItemIDWithTemplate
/**
* @since 1.1.0
* @deprecated 1.2.0
* @use FieldsandfiltersFieldsSite::getFieldsLayoutsByItemID()
**/
public static function getFieldsByItemIDWithTemplate($option = null, $itemID = null, $fieldsID = null, $getAllextensions = true, $params = false, $ordering = 'ordering')
{
$object = self::getFieldsByItemID($option, $itemID, $fieldsID, $getAllextensions);
$templateFields = new JObject();
$fields = $object->fields->getProperties();
if (empty($fields)) {
return $templateFields;
}
$fields = new JObject(JArrayHelper::pivot($fields, 'field_type'));
JPluginHelper::importPlugin('fieldsandfilterstypes');
FieldsandfiltersFactory::getDispatcher()->trigger('getFieldsandfiltersFieldsHTML', array($templateFields, $fields, $object->element, $params, $ordering));
return $templateFields;
}
示例6: _onFieldsandfiltersContent
/**
* @since 1.1.0
*/
protected function _onFieldsandfiltersContent($location, &$row, &$params, $page, $context)
{
if (!($extensionContent = FieldsandfiltersFactory::getExtensions()->getExtensionsByName($this->_name)->get($this->_name))) {
return;
}
// Load Fields Helper
$fieldsHelper = FieldsandfiltersFactory::getFields();
$extensionsParams = new JObject(array('module.off' => true, 'plugin.value' => $this->params->get('use_static_fields')));
// Load Extensions Helper
if ($isStaticFields = FieldsandfiltersExtensionsHelper::getParams('use_static_fields', $extensionsParams, true)) {
// Load Plugin Types Helper
$staticMode = FieldsandfiltersModes::getMode(FieldsandfiltersModes::MODE_STATIC);
if ($fieldsStatic = $fieldsHelper->getFieldsByModeIDPivot('location', $extensionContent->content_type_id, $staticMode, 1, 2)->get($location)) {
$fieldsStatic = is_array($fieldsStatic) ? $fieldsStatic : array($fieldsStatic);
} else {
$isStaticFields = false;
}
}
// Load elements Helper
if (!($element = FieldsandfiltersFactory::getElements()->getElementsByItemIDPivot('item_id', $extensionContent->content_type_id, $row->id, $row->state, 3)->get($row->id)) && !$isStaticFields) {
return;
}
if ($element) {
$fieldsID = array_merge(array_keys($element->connections->getProperties(true)), array_keys($element->data->getProperties(true)));
if (empty($fieldsID) && !$isStaticFields) {
return;
}
if (!($fields = $fieldsHelper->getFieldsByIDPivot('location', $extensionContent->content_type_id, $fieldsID, 1, 1)->get($location)) && !$isStaticFields) {
return;
}
} else {
$fields = false;
}
if ($fields && $isStaticFields) {
$fields = is_array($fields) ? $fields : array($fields);
$fields = array_merge($fields, $fieldsStatic);
} else {
if ($fields) {
$fields = is_array($fields) ? $fields : array($fields);
} else {
if ($isStaticFields) {
$fields = $fieldsStatic;
}
}
}
$fields = new JObject(JArrayHelper::pivot((array) $fields, 'type'));
$layoutFields = new JObject();
JPluginHelper::importPlugin('fieldsandfilterstypes');
// Trigger the onFieldsandfiltersPrepareFormField event.
JFactory::getApplication()->triggerEvent('getFieldsandfiltersFieldsHTML', array($layoutFields, $fields, $element, $context));
$layoutFields = $layoutFields->getProperties(true);
if (empty($layoutFields)) {
return;
}
ksort($layoutFields);
return implode("\n", $layoutFields);
}
示例7: ajax_check_database
/**
* We want to allow html so we need to overwrite some request data
*
* @author Max Milbers
*/
public function ajax_check_database()
{
$db = JFactory::getDbo();
$prefix = 'me1u8_tsmart';
$app = JFactory::getApplication();
$input = $app->input;
$json_database_path_file = 'administrator/components/com_tsmart/views/utility/tmpl/json_database/json_database.txt';
$json_database = JFile::read(JPATH_ROOT . '/' . $json_database_path_file);
$json_database = json_decode($json_database);
$list_table = array();
foreach ($json_database as $table => $rows) {
$list_table[] = $table;
}
$list_table = self::synchronous_table($list_table, $prefix);
$list_table_exists = $db->setQuery("SHOW TABLES")->loadColumn();
foreach ($json_database as $table => $rows) {
foreach ($rows as $key => $row) {
$size = $row->size;
$sql = $row->sql;
switch ($sql) {
case 'INTEGER':
case 'FLOAT':
$sql = 'int';
$size = $size ? $size : 11;
$rows[$key]->size = $size;
$rows[$key]->sql = $sql;
break;
case 'MEDIUMTEXT':
$rows[$key]->size = $size;
break;
case 'VARCHAR':
$size = $size ? $size : 200;
$rows[$key]->size = $size;
break;
}
}
$list_row = JArrayHelper::pivot($rows, 'row_name');
$list_row = array_change_key_case($list_row, CASE_LOWER);
if (in_array($table, $list_table_exists)) {
$sql = "SHOW INDEX FROM `{$table}`";
$list_index = $db->setQuery($sql)->loadObjectList();
$exists_primary_key = false;
$exists_index_key = false;
$list_primary_key = array();
foreach ($list_index as $index) {
if ($index->Key_name == 'PRIMARY') {
$exists_primary_key = true;
$list_primary_key[] = $index->Column_name;
}
if ($index->Cardinality == 18) {
$exists_index_key = true;
}
}
if ($exists_primary_key && !$exists_index_key) {
$first_primary_key = reset($list_primary_key);
$sql = "ALTER TABLE `{$table}` ADD INDEX(`{$first_primary_key}`)";
$ok = $db->setQuery($sql)->execute();
if (!$ok) {
throw new Exception($db->getErrorMsg(), 505);
}
}
if ($exists_primary_key) {
if (count($list_primary_key) > 1) {
}
$sql = "ALTER TABLE `{$table}` DROP PRIMARY KEY";
$ok = $db->setQuery($sql)->execute();
if (!$ok) {
throw new Exception($db->getErrorMsg(), 505);
}
}
$fields = $db->getTableColumns($table);
$fields = array_change_key_case($fields, CASE_LOWER);
foreach ($list_row as $field => $item) {
if ($fields[$field]) {
$current_type_field = $fields[$field];
$item_row = $item;
$ai = $item_row->ai;
$nll = $item_row->nll;
$nll = $nll ? ' NULL ' : ' NOT NULL ';
if ($ai) {
$nll = ' NOT NULL ';
}
$size = $item_row->size;
$str_sql = $item_row->sql;
$size = $size ? "({$size})" : '';
$sql = "ALTER TABLE `{$table}` CHANGE `{$field}` `{$field}` {$str_sql}{$size} {$nll} ";
$db->redirectPage(false);
$result = $db->setQuery($sql)->execute();
if (!$result) {
//echo $db->getErrorMsg();
//die;
//vmError($db->getErrorMsg());
}
$is_primary = $item_row->is_primary;
if ($ai & $is_primary) {
//.........这里部分代码省略.........
示例8: get_list_price
public function get_list_price()
{
$app = JFactory::getApplication();
$input = $app->input;
$price_id = $input->get('price_id', 0, 'int');
$price_type = $input->get('price_type', '', 'string');
$model_price = tmsModel::getModel('price');
$model_price->setId($price_id);
$price = $model_price->getPrice();
$return_item = new stdClass();
$return_item->price = $price;
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php';
$tour_id = $input->get('tsmart_product_id', 0, 'int');
$this->tsmart_product_id = $tour_id;
$model_product = tmsModel::getModel('product');
$product = $model_product->getItem($this->tsmart_product_id);
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php';
if ($price_type != tsmGroupSize::FLAT_PRICE) {
$return_item->list_tour_price_by_tour_price_id = vmprice::get_list_tour_price_by_tour_price_id($price_id);
} else {
$return_item->tour_private_price_by_tour_price_id = vmprice::get_list_tour_price_by_tour_price_id_for_price($price_id);
}
//get markup
$return_item->list_mark_up = vmprice::get_list_mark_up_by_tour_price_id($price_id);
$return_item->list_mark_up = JArrayHelper::pivot($return_item->list_mark_up, 'type');
//end get markup
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php';
$return_item->list_group_size_by_tour_id = vmprice::get_list_group_size_by_tour_id($tour_id);
echo json_encode($return_item);
die;
}