Returns available formats

@param string $context
@return array
486791
protected function getFormatChoices($context = 'prestacms')
    {
        $formatChoices = array();

        $formats = $this->getMediaPool()->getFormatNamesByContext($context);

        foreach ($formats as $code => $format) {
            $formatChoices[$code] = $this->trans('media.format.' . $code);
        }

        return $formatChoices;
    }
75654
private function nestContext(&$context)
    {
        foreach ($context as $key => $value) {
            $dot = strpos($key, '.');
            if ($dot && $dot !== strlen($key) - 1) {
                $currentContext = &$context;
                foreach (explode('.', $key) as $k) {
                    if (!isset($currentContext[$k])) {
                        $currentContext[$k] = [];
                    }
                    $currentContext = &$currentContext[$k];
                }
                $currentContext = $value;
                unset($context[$key]);
            }
        }

        return $context;
    }
1070538
public static function getFormats() : array
    {
        return [
            self::FORMAT_GSM => self::FORMAT_GSM,
            self::FORMAT_UNICODE => self::FORMAT_UNICODE,
            self::FORMAT_BINARY => self::FORMAT_BINARY,
            self::FORMAT_WAPPUSH => self::FORMAT_WAPPUSH,
            self::FORMAT_MMS => self::FORMAT_MMS
        ];
    }
1232881
private function getProxySettings(RequestContext $context): array
    {
        $proxy = [];

        if (!is_null($context->getProxy())) {
            $proxy[CURLOPT_PROXY] = $context->getProxy();
        }

        return $proxy;
    }
766448
public function loadContext($context)
    {

        $ok = false;
        if (!empty($context->getRecordId())) {
            $sql = sprintf('SELECT context_pk, consumer_pk, lti_context_id, type, settings, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::CONTEXT_TABLE_NAME . ' ' .
                           'WHERE (context_pk = %d)',
                           $context->getRecordId());
        } else {
            $sql = sprintf('SELECT context_pk, consumer_pk, lti_context_id, type, settings, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::CONTEXT_TABLE_NAME . ' ' .
                           'WHERE (consumer_pk = %d) AND (lti_context_id = %s)',
                           $context->getConsumer()->getRecordId(), DataConnector::quoted($context->ltiContextId));
        }
        $rs_context = mysql_query($sql);
        if ($rs_context) {
            $row = mysql_fetch_object($rs_context);
            if ($row) {
                $context->setRecordId(intval($row->context_pk));
                $context->setConsumerId(intval($row->consumer_pk));
                $context->ltiContextId = $row->lti_context_id;
                $context->type = $row->type;
                $settings = unserialize($row->settings);
                if (!is_array($settings)) {
                    $settings = array();
                }
                $context->setSettings($settings);
                $context->created = strtotime($row->created);
                $context->updated = strtotime($row->updated);
                $ok = true;
            }
        }

        return $ok;

    }
636425
public function process($context)
    {
        $contents = $context->getContents();
        $contents = preg_replace_callback('/<\?=((?!\?>).)*\?>/s', function ($match) use ($context) {
            return $context->getPlaceholderContainer()->createPlaceholder($match[0]);
        }, $contents);
        $contents = preg_replace_callback('/<\?php((?!\?>).)*(\?>)?/s', function ($match) use ($context) {
            return $context->getPlaceholderContainer()->createPlaceholder($match[0]);
        }, $contents);

        return $context->setContents($contents);
    }
449120
public function formatBlocks(FormatContext $formatContext): array
    {
        $this->arrayLoader->setTemplate(
            $formatContext->templateId(),
            $this->massageTemplate($formatContext)
        );
        $data = $formatContext->data()->export();
        $template = $this->twig->loadTemplate($formatContext->templateId());

        if (!count($blockNames = $this->findAllBlocks($template, $data))) {
            return ['content' => $template->render($data)];
        }
        $blocks = [];
        foreach ($blockNames as $blockName) {
            $blocks[$blockName] = $template->renderBlock($blockName, $data);
        }

        return $blocks;
    }
327212
public function serialize(SpanContext $context)
    {
        $spanHex = str_pad($context->spanId(), 16, "0", STR_PAD_LEFT);
        $traceOptions = $context->enabled() ? self::OPTION_ENABLED : 0;
        return pack("CCH*CH*CC", 0, 0, $context->traceId(), 1, $spanHex, 2, $traceOptions);
    }
424927
public function saveContext($context) {
        global $DB;
        $now = time();
        $context->updated = $now;
        $settingsvalue = serialize($context->getSettings());
        $id = $context->getRecordId();
        $consumerpk = $context->getConsumer()->getRecordId();

        $isinsert = empty($id);
        if ($isinsert) {
            $context->created = $now;
            $params = [
                'consumerid' => $consumerpk,
                'lticontextkey' => $context->ltiContextId,
                'type' => $context->type,
                'settings' => $settingsvalue,
                'created' => $context->created,
                'updated' => $context->updated,
            ];
            $id = $DB->insert_record($this->contexttable, (object) $params);
            if ($id) {
                $context->setRecordId($id);
                return true;
            }
        } else {
            $data = (object) [
                'id' => $id,
                'contextid' => $consumerpk,
                'lticontextkey' => $context->ltiContextId,
                'type' => $context->type,
                'settings' => $settingsvalue,
                'updated' => $context->updated,
            ];
            return $DB->update_record($this->contexttable, $data);
        }

        return false;
    }
339057
public function getActions($context = 'bottom')
    {
        $returnValue = array();

		if(isset($this->actions[$context])){
			$returnValue = $this->actions[$context];
		}

        return (array) $returnValue;
    }
104218
public function value_editor_options(\context $context = null) {
        global $CFG;
        require_once($CFG->libdir.'/formslib.php');
        if (!$context) {
            $context = $this->get_handler()->get_configuration_context();
        }
        return ['maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'context' => $context];
    }
1182364
public function getUpgrades($context = null) {
        if (! $context) {
                $context = $this->getContext();
            }

        if (isset($this->_upgradeStack[$context])) {
            return $this->_upgradeStack[$context];
        }
        return array();
    }
292280
protected function get_string_filters($context) {
        if (!isset($this->stringfilters[$context->id])) {
            $this->load_filters($context);
        }
        return $this->stringfilters[$context->id];
    }
1205242
public function getChildTemplates(string $context): array
    {
        Splash::log()->Deb('Loading Standalone Connector Templates for '.$context);
        $result = array();
        //====================================================================//
        // Safety Check
        if (!in_array($context, array('New', 'Offline', 'Connected'), true)) {
            return $result;
        }
        //====================================================================//
        // Load templates for All Objects
        foreach ($this->getAvailableObjects() as $objectType) {
            $objectService = $this->getObjectService($objectType);
            if (method_exists($objectService, 'get'.$context.'Template')) {
                $result[] = $objectService->{'get'.$context.'Template'}();
            }
        }
        //====================================================================//
        // Return Results
        return $result;
    }
1173641
private function getDefaultSettings(RequestContext $context): array
    {
        $defaults = [
            CURLOPT_ENCODING => "",
            CURLOPT_USERAGENT => "php-nano-rest",
            CURLOPT_HEADER => true,
            CURLOPT_HTTPHEADER => array_values($context->getRequestHeaders()),
            CURLOPT_RETURNTRANSFER => true,
        ];

        return $defaults;
    }
1347013
public function readContextCallees(ContextEnvironment $environment, $contextClass)
    {
        $reflClass = new \ReflectionClass($contextClass);

        if (!$reflClass->implementsInterface('Behat\Behat\Context\TranslatableContext')) {
            return array();
        }

        $assetsId = $environment->getSuite()->getName();
        foreach (call_user_func(array($contextClass, 'getTranslationResources')) as $path) {
            $this->addTranslationResource($path, $assetsId);
        }

        return array();
    }
126139
protected function getFactoryOptions(array $context): array
    {
        $options = [];

        if (isset($context[self::GROUPS])) {
            $options['serializer_groups'] = $context[self::GROUPS];
        }

        if (isset($context['collection_operation_name'])) {
            $options['collection_operation_name'] = $context['collection_operation_name'];
        }

        if (isset($context['item_operation_name'])) {
            $options['item_operation_name'] = $context['item_operation_name'];
        }

        return $options;
    }