当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayHelper::getColumn方法代码示例

本文整理汇总了PHP中Joomla\Utilities\ArrayHelper::getColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::getColumn方法的具体用法?PHP ArrayHelper::getColumn怎么用?PHP ArrayHelper::getColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Joomla\Utilities\ArrayHelper的用法示例。


在下文中一共展示了ArrayHelper::getColumn方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getItems

 /**
  * Overrides the getItems method to attach additional metrics to the list.
  *
  * @return  mixed  An array of data items on success, false on failure.
  *
  * @since   1.6.1
  */
 public function getItems()
 {
     // Get a storage key.
     $store = $this->getStoreId('getItems');
     // Try to load the data from internal storage.
     if (!empty($this->cache[$store])) {
         return $this->cache[$store];
     }
     // Load the list items.
     $items = parent::getItems();
     // If emtpy or an error, just return.
     if (empty($items)) {
         return array();
     }
     // Getting the following metric by joins is WAY TOO SLOW.
     // Faster to do three queries for very large menu trees.
     // Get the menu types of menus in the list.
     $db = $this->getDbo();
     $menuTypes = ArrayHelper::getColumn((array) $items, 'menutype');
     // Quote the strings.
     $menuTypes = implode(',', array_map(array($db, 'quote'), $menuTypes));
     // Get the published menu counts.
     $query = $db->getQuery(true)->select('m.menutype, COUNT(DISTINCT m.id) AS count_published')->from('#__menu AS m')->where('m.published = 1')->where('m.menutype IN (' . $menuTypes . ')')->group('m.menutype');
     $db->setQuery($query);
     try {
         $countPublished = $db->loadAssocList('menutype', 'count_published');
     } catch (RuntimeException $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Get the unpublished menu counts.
     $query->clear('where')->where('m.published = 0')->where('m.menutype IN (' . $menuTypes . ')');
     $db->setQuery($query);
     try {
         $countUnpublished = $db->loadAssocList('menutype', 'count_published');
     } catch (RuntimeException $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Get the trashed menu counts.
     $query->clear('where')->where('m.published = -2')->where('m.menutype IN (' . $menuTypes . ')');
     $db->setQuery($query);
     try {
         $countTrashed = $db->loadAssocList('menutype', 'count_published');
     } catch (RuntimeException $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Inject the values back into the array.
     foreach ($items as $item) {
         $item->count_published = isset($countPublished[$item->menutype]) ? $countPublished[$item->menutype] : 0;
         $item->count_unpublished = isset($countUnpublished[$item->menutype]) ? $countUnpublished[$item->menutype] : 0;
         $item->count_trashed = isset($countTrashed[$item->menutype]) ? $countTrashed[$item->menutype] : 0;
     }
     // Add the items to the internal cache.
     $this->cache[$store] = $items;
     return $this->cache[$store];
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:65,代码来源:menus.php

示例2: getColumn

 /**
  * Extracts a column from an array of arrays or objects
  *
  * @param   array   &$array  The source array
  * @param   string  $index   The index of the column or name of object property
  *
  * @return  array  Column of values from the source array
  *
  * @since   11.1
  * @deprecated  4.0 Use Joomla\Utilities\ArrayHelper::getColumn instead
  */
 public static function getColumn(&$array, $index)
 {
     $result = array();
     if (is_array($array)) {
         $result = ArrayHelper::getColumn($array, $index);
     } else {
         JLog::add('This method is typehinted to be an array in \\Joomla\\Utilities\\ArrayHelper::getColumn.', JLog::WARNING, 'deprecated');
     }
     return $result;
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:21,代码来源:arrayhelper.php

示例3: testDelete

    /**
     * @covers Windwalker\DataMapper\AbstractDataMapper::delete
     * @todo   Implement testDelete().
     */
    public function testDelete()
    {
        $dataset = $this->object->find(array(new Compare('title', 'Rose%', 'LIKE')));
        $this->object->delete(array(new Compare('title', 'Rose%', 'LIKE')));
        $ids = implode(',', ArrayHelper::getColumn((array) $dataset, 'id'));
        $compareContent = $this->db->setQuery(<<<SQL
SELECT *
FROM ww_content
WHERE id IN ({$ids})
SQL
)->loadObjectList();
        $compareContent2 = $this->db->setQuery(<<<SQL
SELECT *
FROM ww_content2
WHERE content_id IN ({$ids})
SQL
)->loadObjectList();
        $this->assertEmpty($compareContent, 'Records not deleted.');
        $this->assertEmpty($compareContent2, 'Records not deleted.');
    }
开发者ID:beingsane,项目名称:quickcontent,代码行数:24,代码来源:OtoDataMapperTest.php

示例4: js

 /**
  * Get JS
  *
  * @param array $res
  */
 private function js($res = array())
 {
     $at = (string) $this->getAttribute('at', 'false');
     if ($at === 'true') {
         FabrikHelperHTML::atWHo('textarea[data-at]', ArrayHelper::getColumn($res, 'value'));
     }
     $connection = $this->getAttribute('connection');
     $repeat = FabrikWorker::toBoolean($this->getAttribute('repeat', false), false);
     $repeat = FabrikAdminElementHelper::getRepeat($this) || $repeat;
     $c = (int) FabrikAdminElementHelper::getRepeatCounter($this);
     $mode = $this->getAttribute('mode');
     $connectionDd = $repeat ? $connection . '-' . $c : $connection;
     $highlightPk = FabrikWorker::toBoolean($this->getAttribute('highlightpk', false), false);
     $tableDd = $this->getAttribute('table');
     $opts = new stdClass();
     $opts->table = $repeat ? 'jform_' . $tableDd . '-' . $c : 'jform_' . $tableDd;
     $opts->conn = 'jform_' . $connectionDd;
     $opts->value = $this->value;
     $opts->repeat = $repeat;
     $opts->showAll = (int) $this->getAttribute('showall', '1');
     $opts->highlightpk = (int) $highlightPk;
     $opts->mode = $mode;
     $opts->defaultOpts = $res;
     $opts->addBrackets = FabrikWorker::toBoolean($this->getAttribute('addbrackets', false), false);
     $opts = json_encode($opts);
     $script = array();
     $script[] = "if (typeOf(FabrikAdmin.model.fields.listfields) === 'null') {";
     $script[] = "FabrikAdmin.model.fields.listfields = {};";
     $script[] = "}";
     $script[] = "if (FabrikAdmin.model.fields.listfields['{$this->id}'] === undefined) {";
     $script[] = "FabrikAdmin.model.fields.listfields['{$this->id}'] = new ListFieldsElement('{$this->id}', {$opts});";
     $script[] = "}";
     $script = implode("\n", $script);
     $srcs = array('Fabrik' => 'media/com_fabrik/js/fabrik.js', 'ListFields' => 'administrator/components/com_fabrik/models/fields/listfields.js');
     FabrikHelperHTML::script($srcs, $script);
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:41,代码来源:listfields.php

示例5: onLoadData

 /**
  * List model has loaded its data, lets pivot it!
  *
  * @param   &$args  Array  Additional options passed into the method when the plugin is called
  *
  * @return bool currently ignored
  */
 public function onLoadData(&$args)
 {
     $data =& $args[0]->data;
     $params = $this->getParams();
     $sums = $params->get('pivot_sum');
     list($xCol, $yCol) = $this->getCols();
     $rawSums = $sums . '_raw';
     // Get distinct areas?
     $xCols = array();
     foreach ($data as $group) {
         foreach ($group as $row) {
             if (!in_array($row->{$xCol}, $xCols)) {
                 $xCols[] = $row->{$xCol};
             }
         }
     }
     // Order headings
     asort($xCols);
     // Get distinct dates
     $yCols = array();
     foreach ($data as $group) {
         foreach ($group as $row) {
             if (!in_array($row->{$yCol}, $yCols)) {
                 $yCols[] = $row->{$yCol};
             }
         }
     }
     $new = array();
     foreach ($yCols as $yColData) {
         $newRow = new stdClass();
         $newRow->{$yCol} = $yColData;
         $total = 0;
         // Set default values
         foreach ($xCols as $xColData) {
             $newRow->{$xColData} = '';
         }
         foreach ($data as $group) {
             foreach ($group as $row) {
                 foreach ($xCols as $xColData) {
                     if ($row->{$xCol} === $xColData && $row->{$yCol} === $yColData) {
                         $newRow->{$xColData} = $row->{$sums};
                         $total += (double) $this->unNumberFormat($row->{$sums}, $params);
                         //$total += (float) $row->$rawSums;
                     }
                 }
             }
         }
         $newRow->pivot_total = $total;
         $new[] = $newRow;
     }
     /**
      * Optionally order by the sum column. I'm sure there's some more elegant way of doing this,
      * but for now, two usort functions will do it.
      */
     $order = $params->get('pivot_sort', '0');
     if ($order == '1') {
         usort($new, function ($a, $b) {
             if ($a->pivot_total == $b->pivot_total) {
                 return 0;
             } else {
                 if ($a->pivot_total > $b->pivot_total) {
                     return -1;
                 } else {
                     return 1;
                 }
             }
         });
     } else {
         if ($order == '2') {
             usort($new, function ($a, $b) {
                 if ($a->pivot_total == $b->pivot_total) {
                     return 0;
                 } else {
                     if ($a->pivot_total < $b->pivot_total) {
                         return -1;
                     } else {
                         return 1;
                     }
                 }
             });
         }
     }
     // Add totals @ bottom
     $yColTotals = new stdClass();
     $yColTotals->{$yCol} = FText::_('PLG_LIST_PIVOT_LIST_Y_TOTAL');
     $total = 0;
     foreach ($xCols as $x) {
         if (!empty($x)) {
             $c = ArrayHelper::getColumn($new, $x);
             $yColTotals->{$x} = 0;
             foreach ($c as &$cc) {
                 $cc = strip_tags($cc);
                 $yColTotals->{$x} += $this->unNumberFormat($cc, $params);
//.........这里部分代码省略.........
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:101,代码来源:pivot.php

示例6: foreach

<?php

if (!empty($categories)) {
    ?>
<div class="max-height-200 list-group-item">
    
    <?php 
    $current = \Joomla\Utilities\ArrayHelper::getColumn((array) $flash->old('categories'), 'id');
    ?>
    <?php 
    foreach ($categories as $one) {
        ?>
    <div class="checkbox">
        <label>
            <input type="checkbox" name="category_ids[]" class="icheck-input" value="<?php 
        echo $one->_id;
        ?>
" <?php 
        if (in_array($one->_id, $current)) {
            echo "checked='checked'";
        }
        ?>
>
            <?php 
        echo @str_repeat("&ndash;", substr_count(@$one->path, "/") - 1) . " " . $one->title;
        ?>
        </label>
    </div>
    <?php 
    }
    ?>
开发者ID:ammonitenetworks,项目名称:f3-forums,代码行数:31,代码来源:checkboxes.php

示例7: buildQuery


//.........这里部分代码省略.........
         // $$$ rob if no ordering applied i had results where main record (e.g. UK) was shown in 2 lines not next to each other
         // causing them not to be merged and a 6 rows shown when limit set to 5. So below, if no order by set then order by main pk asc
         $by = trim($table->order_by) === '' ? array() : (array) json_decode($table->order_by);
         if (empty($by)) {
             $dir = (array) json_decode($table->order_dir);
             array_unshift($dir, 'ASC');
             $table->order_dir = json_encode($dir);
             $by = (array) json_decode($table->order_by);
             array_unshift($by, $table->db_primary_key);
             $table->order_by = json_encode($by);
         }
         // $$$ rob build order first so that we know of any elements we need to include in the select statement
         $query = $this->buildQueryOrder($query);
         $this->selectedOrderFields = (array) $this->selectedOrderFields;
         $this->selectedOrderFields = array_unique(array_merge($lookUps, $this->selectedOrderFields));
         $query->select(implode(', ', $this->selectedOrderFields) . ' FROM ' . $db->qn($table->db_table_name));
         $query = $this->buildQueryJoin($query);
         $query = $this->buildQueryWhere($input->get('incfilters', 1), $query);
         $query = $this->buildQueryGroupBy($query);
         // Can't limit the query here as this gives incorrect _data array.
         // $db->setQuery($query, $this->limitStart, $this->limitLength);
         $db->setQuery($query);
         FabrikHelperHTML::debug((string) $query, 'table:mergeJoinedData get ids');
         $ids = array();
         $idRows = $db->loadObjectList();
         $maxPossibleIds = count($idRows);
         // An array of the lists pk values
         $mainKeys = array();
         foreach ($idRows as $r) {
             $mainKeys[] = $db->q($r->__pk_val0);
         }
         // Chop up main keys for list limitstart, length to cull the data down to the correct length as defined by the page nav/ list settings
         $mainKeys = array_unique($mainKeys);
         if ($this->limitLength > 0) {
             $mainKeys = array_slice($mainKeys, $this->limitStart, $this->limitLength);
         }
         /**
          * $$$ rob get an array containing the PRIMARY key values for each joined tables data.
          * Stop as soon as we have a set of ids totaling the sum of records contained in $idRows
          */
         while (count($ids) < $maxPossibleIds && $lookupC >= 0) {
             $ids = ArrayHelper::getColumn($idRows, '__pk_val' . $lookupC);
             for ($idx = count($ids) - 1; $idx >= 0; $idx--) {
                 if ($ids[$idx] == '') {
                     unset($ids[$idx]);
                 } else {
                     $ids[$idx] = $db->q($ids[$idx]);
                 }
             }
             if (count($ids) < $maxPossibleIds) {
                 $lookupC--;
             }
         }
     }
     // Now lets actually construct the query that will get the required records:
     $query->clear();
     unset($this->orderBy);
     $query = $this->buildQuerySelect('list', $query);
     JDEBUG ? $profiler->mark('queryselect: got') : null;
     $query = $this->buildQueryJoin($query);
     JDEBUG ? $profiler->mark('queryjoin: got') : null;
     if ($this->mergeJoinedData()) {
         /* $$$ rob We've already used buildQueryWhere to get our list of main pk ids.
          * so lets use that list of ids to create the where statement. This will return 5/10/20 etc
          * records from our main table, as per our page nav, even if a main record has 3 rows of joined
          * data. If no ids found then do where "2 = -2" to return no records (was "1 = -1", changed to make
          * it easier to know where this is coming form when debugging)
          */
         if (!empty($ids)) {
             if ($lookUpNames[$lookupC] !== $table->db_primary_key) {
                 $query->where($lookUpNames[$lookupC] . ' IN (' . implode(array_unique($ids), ',') . ')');
             }
             if (!empty($mainKeys)) {
                 // Limit to the current page
                 $query->where($table->db_primary_key . ' IN (' . implode($mainKeys, ',') . ')');
             } else {
                 $query->where('2 = -2');
             }
         } else {
             $query->where('2 = -2');
         }
     } else {
         // $$$ rob we aren't merging joined records so lets just add the standard where query
         // Incfilters set when exporting as CSV
         $query = $this->buildQueryWhere($input->get('incfilters', 1), $query);
     }
     $query = $this->buildQueryGroupBy($query);
     $query = $this->buildQueryOrder($query);
     $query = $this->pluginQuery($query);
     $this->mainQuery = $query;
     /*
     $params = $this->getParams();
     
     if ($params->get('force_collate', '') !== '')
     {
     	$query .= ' COLLATE ' . $params->get('force_collate', '') . ' ';
     }
     */
     return (string) $query;
 }
开发者ID:pascal26,项目名称:fabrik,代码行数:101,代码来源:list.php

示例8: implode

</a></legend>
		                        		</div>
                        			</div>
                        			<div class="row">
		                        		<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
		                        			<div>
		                        				<label>Slug:</label> <a target="_blank" href="./striper/plan/<?php 
        echo $item->id;
        ?>
"><?php 
        echo $item->id;
        ?>
 <i class="fa fa-external-link"></i></a>
		                        			</div>
		                        			<?php 
        $categories = \Joomla\Utilities\ArrayHelper::getColumn((array) $item->categories, 'title');
        ?>
		                        			<?php 
        if ($categories) {
            ?>
		                        			<div>			                        			
		                        				<label>Categories:</label>
												<span class='label label-warning'><?php 
            echo implode("</span> <span class='label label-warning'>", (array) $categories);
            ?>
</span>
		                        			</div>
		                        			<?php 
        }
        ?>
		                        			<?php 
开发者ID:dioscouri,项目名称:f3-striper,代码行数:31,代码来源:list.php

示例9: update

 /**
  * Run when the component is updated
  *
  * @param   object $parent installer object
  *
  * @return  bool
  */
 public function update($parent)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $app = JFactory::getApplication();
     $msg = array();
     // Fabrik 3.5 Uninstalled plugins.
     $plugins = array('fabrik_element' => array('fbactivityfeed', 'fblikebox', 'fbrecommendations'), 'fabrik_form' => array('vbforum'));
     // Deprecated - 'timestamp', 'exif'
     $query->select('*')->from('#__extensions');
     foreach ($plugins as $folder => $plugs) {
         $query->where('(folder = ' . $db->q($folder) . ' AND element IN (' . implode(', ', $db->q($plugs)) . '))', 'OR');
         foreach ($plugs as $plug) {
             $path = JPATH_PLUGINS . '/' . $folder . '/' . $plug;
             if (JFolder::exists($path)) {
                 JFolder::delete($path);
             }
         }
     }
     $deprecatedPlugins = $db->setQuery($query)->loadObjectList();
     if (!empty($deprecatedPlugins)) {
         $ids = ArrayHelper::getColumn($deprecatedPlugins, 'extension_id');
         $ids = ArrayHelper::toInteger($ids);
         $query->clear()->delete('#__extensions')->where('extension_id IN ( ' . implode(',', $ids) . ')');
         $db->setQuery($query)->execute();
         // Un-publish elements
         $query->clear()->select('id, name, label')->from('#__fabrik_elements')->where('plugin IN (' . implode(', ', $db->q($plugins['fabrik_element'])) . ')')->where('published = 1');
         $db->setQuery($query);
         $unpublishedElements = $db->loadObjectList();
         $unpublishedIds = ArrayHelper::getColumn($unpublishedElements, 'id');
         if (!empty($unpublishedIds)) {
             $msg[] = 'The following elements have been unpublished as their plug-ins have been uninstalled. : ' . implode(', ', $unpublishedIds);
             $query->clear()->update('#__fabrik_elements')->set('published = 0')->where('id IN (' . implode(',', $db->q($unpublishedIds)) . ')');
             $db->setQuery($query)->execute();
         }
     }
     // Un-publish form plug-ins
     $query->clear()->select('id, params')->from('#__fabrik_forms');
     $forms = $db->setQuery($query)->loadObjectList();
     foreach ($forms as $form) {
         $params = json_decode($form->params);
         $found = false;
         if (isset($params->plugins)) {
             for ($i = 0; $i < count($params->plugins); $i++) {
                 if (in_array($params->plugins[$i], $plugins['fabrik_form'])) {
                     $msg[] = 'Form ' . $form->id . '\'s plugin \'' . $params->plugins[$i] . '\' has been unpublished';
                     $params->plugin_state[$i] = 0;
                     $found = true;
                 }
             }
             if ($found) {
                 $query->clear()->update('#__fabrik_forms')->set('params = ' . $db->q(json_encode($params)))->where('id = ' . (int) $form->id);
                 $db->setQuery($query)->execute();
             }
         }
     }
     if (!empty($msg)) {
         $app->enqueueMessage(implode('<br>', $msg), 'warning');
     }
     return true;
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:68,代码来源:com_fabrik.manifest.class.php

示例10: testGetColumn

 /**
  * Test pulling data from a single column (by index or association).
  *
  * @param   array   $input    Input array
  * @param   mixed   $index    Column to pull, either by association or number
  * @param   array   $expect   The expected results
  * @param   string  $message  The failure message
  *
  * @return  void
  *
  * @dataProvider  seedTestGetColumn
  * @covers        Joomla\Utilities\ArrayHelper::getColumn
  * @since         1.0
  */
 public function testGetColumn($input, $index, $expect, $message)
 {
     $this->assertEquals($expect, ArrayHelper::getColumn($input, $index), $message);
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:18,代码来源:ArrayHelperTest.php

示例11: testFlush

 /**
  * @covers Windwalker\DataMapper\AbstractDataMapper::updateAll
  * @todo   Implement testUpdateAll().
  */
 public function testFlush()
 {
     $mapper = new DataMapper('ww_content_tags');
     $dataset = new DataSet();
     $dataset[] = new Data(array('content_id' => 4, 'tag_id' => 1));
     $dataset[] = new Data(array('content_id' => 4, 'tag_id' => 2));
     $dataset[] = new Data(array('content_id' => 4, 'tag_id' => 4));
     $dataset[] = new Data(array('content_id' => 4, 'tag_id' => 5));
     $mapper->flush($dataset, array('content_id' => 4));
     $tagMaps = $mapper->find(array('content_id' => 4));
     $this->assertEquals(array(1, 2, 4, 5), ArrayHelper::getColumn((array) $tagMaps, 'tag_id'), 'Flush data wrong.');
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:16,代码来源:DataMapperTest.php

示例12: _renderListData

 /**
  * Display the file in the table
  *
  * @param   string  $data     current cell data
  * @param   array   $thisRow  current row data
  *
  * @return	string
  */
 private function _renderListData($data, $thisRow)
 {
     $params = $this->getParams();
     if ($params->get('rating-mode') == 'creator-rating') {
         return $data;
     } else {
         $list = $this->getlistModel()->getTable();
         $listId = $list->id;
         $formId = $list->form_id;
         $d = $this->getListModel()->getData();
         $ids = ArrayHelper::getColumn($d, '__pk_val');
         $rowId = isset($thisRow->__pk_val) ? $thisRow->__pk_val : $thisRow->id;
         list($avg, $total) = $this->getRatingAverage($data, $listId, $formId, $rowId, $ids);
         return $avg;
     }
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:24,代码来源:rating.php


注:本文中的Joomla\Utilities\ArrayHelper::getColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。