addLtiLinkItemExtended - Add an LTI Link Content Item

@param $params Key/Value pair of configurable options for content item (see addLtiLinkItem)
482048
public function addLtiLinkItemExtended($params = array())
    {
        global $CFG;

        // populate the default parameters
        if (empty($params['title']))
            $params['title'] = false;
        if (empty($params['text']))
            $params['text'] = false;
        if (empty($params['icon']))
            $params['icon'] = false;
        if (empty($params['fa_icon']))
            $params['fa_icon'] = false;
        if (empty($params['custom']))
            $params['custom'] = false;
        if (empty($params['points']))
            $params['points'] = false;
        if (empty($params['activityId']))
            $params['activityId'] = false;
        if (empty($params['placementTarget']))
            $params['placementTarget'] = 'iframe';
        if (empty($params['placementWindowTarget']))
            $params['placementWindowTarget'] = '';
        if (empty($params['placementWidth']))
            $params['placementWidth'] = '';
        if (empty($params['placementHeight']))
            $params['placementHeight'] = '';

        $item = '{ "@type" : "LtiLinkItem",
                    "@id" : ":item2",
                    "title" : "A cool tool hosted in the Tsugi environment.",
                    "mediaType" : "application/vnd.ims.lti.v1.ltilink",
                    "text" : "For more information on how to build and host powerful LTI-based Tools quickly, see www.tsugi.org",
                    "url" : "http://www.tsugi.org/",
                    "placementAdvice" : {
                        "presentationDocumentTarget" : "iframe"
                    },
                    "icon" : {
                        "@id" : "https://static.tsugi.org/img/default-icon.png",
                        "fa_icon" : "fa-magic",
                        "width" : 64,
                        "height" : 64
                    },
                    "lineItem" : {
                        "@type" : "LineItem",
                        "label" : "Gradable External Tool",
                        "reportingMethod" : "res:totalScore",
                        "assignedActivity" : {
                            "@id" : "http://toolprovider.example.com/assessment/66400",
                            "activityId" : "a-9334df-33"
                        },
                        "scoreConstraints" : {
                            "@type" : "NumericLimits",
                            "normalMaximum" : 10
                        }
                    }
                }';

        $json = json_decode($item);
        $json->url = $params['url'];
        if ( $params['title'] ) $json->{'title'} = $params['title'];
        if ( $params['text'] ) $json->{'text'} = $params['text'];
        if ( $params['icon'] ) $json->{'icon'}->{'@id'} = $params['icon'];
        if ( $params['fa_icon'] ) $json->icon->fa_icon = $params['fa_icon'];
        if ( $params['custom'] ) $json->custom = $params['custom'];
        if ( $params['points'] && $params['activityId'] ) {
            $json->lineItem->label = $params['title'];
            $json->lineItem->assignedActivity->{'@id'} = $CFG->wwwroot . '/lti/activity/' . $params['activityId'];
            $json->lineItem->assignedActivity->activityId = $params['activityId'];
            $json->lineItem->scoreConstraints->normalMaximum = $params['points'];
        } else {
            unset($json->lineItem);
        }

        if ($params['placementTarget'])
            $json->placementAdvice->presentationDocumentTarget = $params['placementTarget'];
        if ($params['placementWindowTarget'])
            $json->placementAdvice->windowTarget = $params['placementWindowTarget'];
        if (! empty($params['placementWidth']))
            $json->placementAdvice->displayWidth = $params['placementWidth'];
        if (! empty($params['placementHeight']))
            $json->placementAdvice->displayHeight = $params['placementHeight'];

        $json->{'@id'} = ':item'.(count($this->json->{'@graph'})+1);

        $this->json->{'@graph'}[] = $json;
    }
407878
public function addParams($params)
    {
        if (is_null($params)) {
            return;
        }

        if(!is_array($params)) {
            $params = array($params);
        }

        $this->params = array_merge($this->params, $params);
    }
202054
public function addItems( $items )
	{
		if( $items instanceof UI_HTML_Buffer ) 
			$this->addItem( $items->render() );
		else
			foreach( $items as $item )
				$this->addItem( $item );
	}
345861
public function addParam(\Deflection\Element\Param $param)
    {
        $element = $param->getElement();
        $this->params = array_merge($this->params, array(''), $element);
        return $this;
    }
8109
function () {
		var items = _.flatten(arguments);
		for (var i = 0, l = items.length; i < l; i++) {
			this.addItem(items[i], this.items.length);
		}
	}
1375001
public function containerItemsProcFunc(array &$params)
    {
        $this->init($params['row']['pid']);
        $possibleContainers = [];
        $this->removeItemsFromListOfSelectableContainers($params, $possibleContainers);

        if (!empty($possibleContainers)) {
            $params['items'] = array_merge($params['items'], $possibleContainers);
        }
        $itemUidList = '';
        if (count($params['items']) > 1) {
            foreach ($params['items'] as $container) {
                if ($container[1] > 0) {
                    $itemUidList .= $itemUidList ? ',' . $container[1] : $container[1];
                }
            }
        }

        if ($itemUidList) {
            $this->deleteDisallowedContainers($params, $itemUidList);
        }
    }
876418
public function addParamsNavStart($params = [])
    {
        if (is_array($params) && !empty($params))
        {
            $this->navStartParams = array_merge(is_array($this->navStartParams) ? $this->navStartParams : array(), $params);
        }
    }
42783
public function itemsProcFunc(&$params)
    {
        // if this tt_content element is inline element of mask
        if ($params["row"]["colPos"] == $this->colPos) {
            $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper');
            $this->storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Domain\\Repository\\StorageRepository');

            if (isset($_REQUEST["ajax"]["context"])) {
                $ajaxContext = json_decode($_REQUEST["ajax"]["context"]);
                $fieldKey = str_replace("_parent", "", $ajaxContext->config->foreign_field);
            } else {
                $fields = $params["row"];
                foreach ($fields as $key => $field) {
                    // search for the parent field, to get the key of mask field this content element belongs to
                    if ($this->startsWith($key, "tx_mask_") && $this->endsWith($key, "_parent") && $field > 0) {

                        // if a parent field was found, that is filled with a uid, extract the mask field name from it
                        $fieldKey = str_replace("_parent", "", $key);

                        // if one parent field was found, don't continue search, there can only be one parent
                        break;
                    }
                }
            }

            // load the json configuration of this field
            $table = $fieldHelper->getFieldType($fieldKey);
            $fieldConfiguration = $this->storageRepository->loadField($table, $fieldKey);

            // if there is a restriction of cTypes specified
            if (is_array($fieldConfiguration["cTypes"])) {

                // prepare array of allowed cTypes, with cTypes as keys
                $cTypes = array_flip($fieldConfiguration["cTypes"]);

                // and check each item if it is allowed. if not, unset it
                foreach ($params["items"] as $itemKey => $item) {
                    if (!isset($cTypes[$item[1]])) {
                        unset($params["items"][$itemKey]);
                    }
                }
            }
        } else { // if it is not inline tt_content element
            // and if other itemsProcFunc from other extension was available (e.g. gridelements),
            // then call it now and let it render the items
            if (!empty($params["config"]["m_itemsProcFunc"])) {
                \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($params["config"]["m_itemsProcFunc"], $params,
                    $this);
            }
        }
    }
371056
function _addItems(item, $container) {
    if (Array.isArray(item)) {
      item.forEach(function(item) {
        _addItems(item, $container);
      });
    } else if (utils.includesCapability(meta.activeWatchInfo, item.capabilities)) {
      if (item.type === 'section') {
        var $wrapper = HTML('<div class="section">');
        $container.add($wrapper);
        _addItems(item.items, $wrapper);
      } else {
        var _item = _.copyObj(item);
        _item.clayId = _items.length;

        var clayItem = new ClayItem(_item).initialize(self);

        if (_item.id) {
          _itemsById[_item.id] = clayItem;
        }

        if (_item.messageKey) {
          _itemsByMessageKey[_item.messageKey] = clayItem;
        }

        _items.push(clayItem);

        // set the value of the item via the manipulator to ensure consistency
        var value = typeof _settings[_item.messageKey] !== 'undefined' ?
          _settings[_item.messageKey] :
          _item.defaultValue;

        clayItem.set(typeof value !== 'undefined' ? value : '');

        $container.add(clayItem.$element);
      }
    }
  }
42417
private function maybeAddParam($params, $name)
  {
    $param = $this->client->getClassConfig($this, $name);
    if ($param != '') {
      $params[$name] = $param;
    }
    return $params;
  }
120320
private function addItem()
    {
        $args = func_get_args();
        if (in_array($args[0], self::$appendableTransformations)) {
            $i = $this->findLastTransformation($args[0]);
            if ($i !== false) {
                $this->items[$i]['rendered'] .= ','.implode(':', array_slice($args, 1));

                return $this;
            }
        }
        if ($args[0] != '/' && $this->itemCount && in_array($this->items[$this->itemCount - 1]['type'], self::$forcedLastTransformations)) {
            $lastTransformation = array_pop($this->items);
        }
        $this->items[] = [
            'type' => $args[0],
            'rendered' => implode(':', $args),
        ];
        ++$this->itemCount;
        if (isset($lastTransformation)) {
            $this->items[] = $lastTransformation;
        }

        return $this;
    }
1175837
private static function addParams($dom, $params)
	{
		if(!sizeof($params)) {
			return $dom;
		}
		// get xpath
		$xpath = new DOMXPath($dom);
		//registering namespace xsl
		$xpath->registerNamespace(self::XSLT_SHORT_NS, self::XSLT_NS);
		// get the params tag direct child of the stylesheet (don't touch other params as template for example)
		$items = $xpath->query('/' . self::XSLT_SHORT_NS . ':stylesheet|' . self::XSLT_SHORT_NS . ':transform/' . self::XSLT_SHORT_NS . ':param');
		// list existing to don't duplicate it
		$existing = array();
		foreach ($items as $param) {
			$existing[] = $param->getAttribute('name');
		}
		// for each item in param
		foreach ($params as $name => $val) {
			// if not exist in dom
			if(!in_array($name, $existing)) {
				// we add it to the dom
				$node = $dom->createElementNS(self::XSLT_NS, self::XSLT_SHORT_NS . ":param");
				$node->setAttribute('name', $name);
				// log to say param added dynamically
				common_Logger::w('Parameters "' . $name . '"added automatically by the ' . get_class() . ':addParams \'s function because it was missing in the xsl stylesheet');
			}
		}
		return $dom;
	}
723032
public void addParameter(String... paras) {

		for (String parameter : paras) {
			for (String knownDef : parameters) {
				if (parameter.equals(knownDef)) {
					throw new FuzzerException(name + ": parameter '" + parameter + "' already defined");
				}
			}
			parameters.add(parameter);
		}
	}
1044715
protected function addLineItems(array $params, array $options)
    {
        if (isset($options['line_items']) && is_array($options['line_items'])) {
            foreach ($options['line_items'] as $lineItem) {
                $params['line_items'][] = [
                    'name'        => Arr::get($lineItem, 'name'),
                    'description' => Arr::get($lineItem, 'description'),
                    'unit_price'  => (int) $this->gateway->amount(Arr::get($lineItem, 'unit_price')),
                    'quantity'    => Arr::get($lineItem, 'quantity', 1),
                    'sku'         => Arr::get($lineItem, 'sku'),
                    'category'    => Arr::get($lineItem, 'category'),
                    'type'        => Arr::get($lineItem, 'type', 'physical'),
                    'tags'        => ['none'],
                ];
            }
        }

        return $params;
    }
112630
protected function addLineItems(array $params, array $options)
    {
        if (isset($options['line_items']) && is_array($options['line_items'])) {
            $item = 0;
            $params['PAYMENTREQUEST_0_ITEMAMT'] = 0;

            foreach ($options['line_items'] as $lineItem) {
                $params["L_PAYMENTREQUEST_0_NAME{$item}"] = Arr::get($lineItem, 'name');
                $params["L_PAYMENTREQUEST_0_DESC{$item}"] = Arr::get($lineItem, 'description');
                $params["L_PAYMENTREQUEST_0_QTY{$item}"] = Arr::get($lineItem, 'quantity', 1);
                $params["L_PAYMENTREQUEST_0_AMT{$item}"] = $this->gateway->amount(Arr::get($lineItem, 'unit_price'));
                $params['PAYMENTREQUEST_0_ITEMAMT'] += Arr::get($lineItem, 'quantity', 1) * Arr::get($lineItem, 'unit_price');
                $item++;
            }

            if (isset($options['discount'])) {
                $item++;
                $params["L_PAYMENTREQUEST_0_NAME{$item}"] = Arr::get($options, 'discount_concept', 'Discount');
                $params["L_PAYMENTREQUEST_0_DESC{$item}"] = '';
                $params["L_PAYMENTREQUEST_0_QTY{$item}"] = 1;
                $params["L_PAYMENTREQUEST_0_AMT{$item}"] = -$this->gateway->amount($options['discount']);
                $params['PAYMENTREQUEST_0_ITEMAMT'] += -$options['discount'];
            }

            $params['PAYMENTREQUEST_0_ITEMAMT'] = $this->gateway->amount($params['PAYMENTREQUEST_0_ITEMAMT'], false);
        }

        return $params;
    }
616673
public function asset_add_path($params) {
        if (!isset($params['path']))
            throw new \UnexpectedValueException('Asset path must be specified');
        $type = isset($params['type']) ? $params['type'] : null;
        Asset::add_path($params['path'], $type);
    }
57425
public final void append(final AbstractItemLink link) throws SevereMessageStoreException
    {
        if (link.isItemStreamLink())
        {
            _itemStreams.append(link);
        }
        else
        {
            throw new SevereMessageStoreException("Cannot add this directly to message store");
        }
    }