PKPUsageStatsPlugin::addJavascriptData PHP Метод

addJavascriptData() публичный Метод

Add a data set to the script data output
public addJavascriptData ( $data, $pubObjectType, $pubObjectId, $contexts ) : null
$data array JS data to pass to the scripts
$pubObjectType string The type of object this data is for
$pubObjectId string The id of the object this data is for
$contexts string|array Contexts in which to load the scripts.
Результат null
    function addJavascriptData($data, $pubObjectType, $pubObjectId, $contexts)
    {
        // Initialize the name space
        $script_data = 'var pkpUsageStats = pkpUsageStats || {};';
        $script_data .= 'pkpUsageStats.data = pkpUsageStats.data || {};';
        $script_data .= 'pkpUsageStats.data.' . $pubObjectType . ' = pkpUsageStats.data.' . $pubObjectType . ' || {};';
        $namespace = $pubObjectType . '[' . $pubObjectId . ']';
        $script_data .= 'pkpUsageStats.data.' . $namespace . ' = ' . json_encode($data) . ';';
        // Register the data
        $request = Application::getRequest();
        $templateMgr = TemplateManager::getManager($request);
        $templateMgr->addJavaScript('pkpUsageStatsData', $script_data, array('inline' => true, 'contexts' => $contexts));
    }