protected static function checkFileContent() { $fileContent = file_get_contents(static::$tmpFilepath); // check encoding and convert to utf-8 when necessary $detectedEncoding = mb_detect_encoding($fileContent, 'UTF-8, ISO-8859-1, WINDOWS-1252', true); if ($detectedEncoding) { if ($detectedEncoding !== 'UTF-8') { $fileContent = iconv($detectedEncoding, 'UTF-8', $fileContent); } } else { echo 'Zeichensatz der CSV-Date stimmt nicht. Der sollte UTF-8 oder ISO-8856-1 sein.'; return false; } //prepare data array $tmpData = str_getcsv($fileContent, PHP_EOL); array_shift($tmpData); $preparedData = []; $data = array_map(function ($row) use(&$preparedData) { $tmpDataArray = str_getcsv($row, ';'); $tmpKey = trim($tmpDataArray[0]); array_shift($tmpDataArray); $preparedData[$tmpKey] = $tmpDataArray; }, $tmpData); // generate json $jsonContent = json_encode($preparedData, JSON_HEX_TAG | JSON_HEX_AMP); self::$jsonContent = $jsonContent; return true; }
public static function up($html, $spruce) { self::$tokenizer = new PHP_CodeSniffer_Tokenizers_CSS(); // TODO: parse $spruce to see if it's a path or a full Spruce string self::$tokens = self::$tokenizer->tokenizeString(file_get_contents($spruce)); self::$tree = array(); //print_r(self::tokens); reset(self::$tokens); while ($t = current(self::$tokens)) { if ($t['type'] != 'T_OPEN_TAG' && $t['type'] != 'T_DOC_COMMENT' && $t['type'] != 'T_COMMENT') { if ($t['type'] == 'T_ASPERAND') { $temp = next(self::$tokens); switch ($temp['content']) { case 'import': next(self::$tokens); self::addImportRule(); //print_r($temp); continue; case 'media': next(self::$tokens); self::addMediaRule(); continue; } } elseif ($t['type'] == 'T_STRING') { self::addStatement(); } } next(self::$tokens); } return self::$tree; }
/** * Compiles a template and writes it to a cache file, which is used for inclusion. * * @param string $file The full path to the template that will be compiled. * @param array $options Options for compilation include: * - `path`: Path where the compiled template should be written. * - `fallback`: Boolean indicating that if the compilation failed for some * reason (e.g. `path` is not writable), that the compiled template * should still be returned and no exception be thrown. * @return string The compiled template. */ public static function template($file, array $options = array()) { $cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates'; $defaults = array('path' => $cachePath, 'fallback' => false); $options += $defaults; $stats = stat($file); $oname = basename(dirname($file)) . '_' . basename($file, '.php'); $oname .= '_' . ($stats['ino'] ?: hash('md5', $file)); $template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php"; $template = "{$options['path']}/{$template}"; if (file_exists($template)) { return $template; } $compiled = static::compile(file_get_contents($file)); if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) { foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) { if ($expired !== $template) { unlink($expired); } } return $template; } if ($options['fallback']) { return $file; } throw new TemplateException("Could not write compiled template `{$template}` to cache."); }
public function get($limit = 1024) { header('Content-Type: application/json'); $dates = json_decode(file_get_contents('hoa://Application/Database/Dates.json'), true); echo json_encode(array_slice($dates, 0, $limit)); return; }
/** * {@inheritdoc} */ public function run() { if (is_null($this->dst) || "" === $this->dst) { return Result::error($this, 'You must specify a destination file with to() method.'); } if (!$this->checkResources($this->files, 'file')) { return Result::error($this, 'Source files are missing!'); } if (file_exists($this->dst) && !is_writable($this->dst)) { return Result::error($this, 'Destination already exists and cannot be overwritten.'); } $dump = ''; foreach ($this->files as $path) { foreach (glob($path) as $file) { $dump .= file_get_contents($file) . "\n"; } } $this->printTaskInfo('Writing {destination}', ['destination' => $this->dst]); $dst = $this->dst . '.part'; $write_result = file_put_contents($dst, $dump); if (false === $write_result) { @unlink($dst); return Result::error($this, 'File write failed.'); } // Cannot be cross-volume; should always succeed. @rename($dst, $this->dst); return Result::success($this); }
/** * Testing converting not valid cron configuration, expect to get exception * * @expectedException \InvalidArgumentException */ public function testConvertWrongConfiguration() { $xmlFile = __DIR__ . '/_files/sales_invalid.xml'; $dom = new \DOMDocument(); $dom->loadXML(file_get_contents($xmlFile)); $this->_converter->convert($dom); }
public function addFieldToModule($field) { global $log; $fileName = 'modules/Settings/Vtiger/models/CompanyDetails.php'; $fileExists = file_exists($fileName); if ($fileExists) { require_once $fileName; $fileContent = file_get_contents($fileName); $placeToAdd = "'website' => 'text',"; $newField = "'{$field}' => 'text',"; if (self::parse_data($placeToAdd, $fileContent)) { $fileContent = str_replace($placeToAdd, $placeToAdd . PHP_EOL . ' ' . $newField, $fileContent); } else { if (self::parse_data('?>', $fileContent)) { $fileContent = str_replace('?>', '', $fileContent); } $fileContent = $fileContent . PHP_EOL . $placeToAdd . PHP_EOL . ' ' . $newField . PHP_EOL . ');'; } $log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - add line to modules/Settings/Vtiger/models/CompanyDetails.php '); } else { $log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - File does not exist'); return FALSE; } $filePointer = fopen($fileName, 'w'); fwrite($filePointer, $fileContent); fclose($filePointer); return TRUE; }
/** * Config */ public function __construct() { $posts = json_decode(file_get_contents(dirname(__FILE__) . '/posts.json'), true); foreach ($posts as $key => $post) { $this->posts[$key] = (object) $post; } }
/** * Processes the standard headers that are not subdivided into other structs. */ protected function processStandardHeaders() { $req = $this->request; $req->date = isset($_SERVER['REQUEST_TIME']) ? new DateTime("@{$_SERVER['REQUEST_TIME']}") : new DateTime(); if (isset($_SERVER['REQUEST_METHOD'])) { switch ($_SERVER['REQUEST_METHOD']) { case 'POST': $req->protocol = 'http-post'; break; case 'PUT': $req->protocol = 'http-put'; break; case 'DELETE': $req->protocol = 'http-delete'; break; default: $req->protocol = 'http-get'; } } $req->host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain'); $req->uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; // remove the query string from the URI $req->uri = preg_replace('@\\?.*$@', '', $req->uri); // url decode the uri $req->uri = urldecode($req->uri); // remove the prefix from the URI $req->uri = preg_replace('@^' . preg_quote($this->properties['prefix']) . '@', '', $req->uri); $req->requestId = $req->host . $req->uri; $req->referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; $req->variables =& $_REQUEST; if ($req->protocol == 'http-put') { $req->body = file_get_contents("php://input"); } }
function gameStatus() { $homepage = file_get_contents('http://bsx.jlparry.com/status'); $xml = simplexml_load_string($homepage); print_r($xml); return $xml; }
public function testObsoleteDirectives() { $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); $invoker(function ($file) { $this->assertNotRegExp('/\\{\\{htmlescape.*?\\}\\}/i', file_get_contents($file), 'Directive {{htmlescape}} is obsolete. Use {{escapehtml}} instead.'); }, \Magento\Framework\App\Utility\Files::init()->getEmailTemplates()); }
public function execute($url, $data = null) { if ($this->artificialDelay > 0) { sleep($this->artificialDelay); } return file_get_contents(__DIR__ . '/USPSResponse.xml'); }
/** * Entry point for the script * * @return void * * @since 1.0 */ public function doExecute() { jimport('joomla.filesystem.file'); if (file_exists(JPATH_BASE . '/configuration.php') || file_exists(JPATH_BASE . '/config.php')) { $configfile = file_exists(JPATH_BASE . 'configuration.php') ? JPATH_BASE . '/config.php' : JPATH_BASE . '/configuration.php'; if (is_writable($configfile)) { $config = file_get_contents($configfile); //Do a simple replace for the CMS and old school applications $newconfig = str_replace('public $offline = \'0\'', 'public $offline = \'1\'', $config); // Newer applications generally use JSON instead. if (!$newconfig) { $newconfig = str_replace('"public $offline":"0"', '"public $offline":"1"', $config); } if (!$newconfig) { $this->out('This application does not have an offline configuration setting.'); } else { JFile::Write($configfile, &$newconfig); $this->out('Site is offline'); } } else { $this->out('The file is not writable, you need to change the file permissions first.'); $this->out(); } } else { $this->out('This application does not have a configuration file'); } $this->out(); }
/** * @param $url * @param bool $file * * @return bool|null|string * @throws \Exception * * @SuppressWarnings("unused") */ public static function fgetDownload($url, $file = false) { $return = null; if ($file === false) { $return = true; $file = 'php://temp'; } $fileStream = fopen($file, 'wb+'); fwrite($fileStream, file_get_contents($url)); $headers = $http_response_header; $firstHeaderLine = $headers[0]; $firstHeaderLineParts = explode(' ', $firstHeaderLine); if ($firstHeaderLineParts[1] == 301 || $firstHeaderLineParts[1] == 302) { foreach ($headers as $header) { $matches = array(); preg_match('/^Location:(.*?)$/', $header, $matches); $url = trim(array_pop($matches)); return static::fgetDownload($url, $file); } throw new \Exception("Can't get the redirect location"); } if ($return) { rewind($fileStream); $return = stream_get_contents($fileStream); } fclose($fileStream); return $return; }
/** * indexAction action. */ public function indexAction(Request $request, $_format) { $session = $request->getSession(); if ($request->hasPreviousSession() && $session->getFlashBag() instanceof AutoExpireFlashBag) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); } $cache = new ConfigCache($this->exposedRoutesExtractor->getCachePath($request->getLocale()), $this->debug); if (!$cache->isFresh()) { $exposedRoutes = $this->exposedRoutesExtractor->getRoutes(); $serializedRoutes = $this->serializer->serialize($exposedRoutes, 'json'); $cache->write($serializedRoutes, $this->exposedRoutesExtractor->getResources()); } else { $serializedRoutes = file_get_contents((string) $cache); $exposedRoutes = $this->serializer->deserialize($serializedRoutes, 'Symfony\\Component\\Routing\\RouteCollection', 'json'); } $routesResponse = new RoutesResponse($this->exposedRoutesExtractor->getBaseUrl(), $exposedRoutes, $this->exposedRoutesExtractor->getPrefix($request->getLocale()), $this->exposedRoutesExtractor->getHost(), $this->exposedRoutesExtractor->getScheme(), $request->getLocale()); $content = $this->serializer->serialize($routesResponse, 'json'); if (null !== ($callback = $request->query->get('callback'))) { $validator = new \JsonpCallbackValidator(); if (!$validator->validate($callback)) { throw new HttpException(400, 'Invalid JSONP callback value'); } $content = $callback . '(' . $content . ');'; } $response = new Response($content, 200, array('Content-Type' => $request->getMimeType($_format))); $this->cacheControlConfig->apply($response); return $response; }
public static function getLiveScore($requester, $request) { $requestParams = explode(",", $request); $scoreAvailable = false; $team1 = $requestParams[0]; $team2 = $requestParams[1]; $matchList = file_get_contents(self::$cricInfoURL); $message = "Sorry, this match information is not available."; if ($matchList) { $json = json_decode($matchList, true); foreach ($json as $value) { echo $value['t1'] . '/n'; echo $value['t2'] . '/n/n'; if ((stripos($value['t1'], $team1) > -1 || stripos($value['t1'], $team2) > -1) && (stripos($value['t2'], $team1) > -1 || stripos($value['t2'], $team2) > -1)) { $matchScoreURL = self::$cricInfoURL . '?id=' . $value['id']; $matchScore = file_get_contents($matchScoreURL); $matchScore = json_decode($matchScore, true); $score = $matchScore['0']['de']; $scoreAvailable = true; MessaggingController::sendMessage($requester, $score); } } } else { $message = "Service temporarily not available, please try after some time"; } if (!$scoreAvailable) { MessaggingController::sendMessage($requester, $message); } PubSub::publish(GenieConstants::$SERVICE_REQUEST_COMPLETE, $requester); }
function GetCounter() { if (file_exists(COUNTER_FILE)) { return intval(file_get_contents(COUNTER_FILE)); } return 0; }
/** * Return JS configuration of the htmlArea plugins registered by the extension * * @return string JS configuration for registered plugins */ public function buildJavascriptConfiguration() { $schema = array('types' => array(), 'properties' => array()); // Parse configured schemas if (is_array($this->configuration['thisConfig']['schema.']) && is_array($this->configuration['thisConfig']['schema.']['sources.'])) { foreach ($this->configuration['thisConfig']['schema.']['sources.'] as $source) { $fileName = trim($source); $absolutePath = GeneralUtility::getFileAbsFileName($fileName); // Fallback to default schema file if configured file does not exists or is of zero size if (!$fileName || !file_exists($absolutePath) || !filesize($absolutePath)) { $fileName = 'EXT:' . $this->extensionKey . '/Resources/Public/Rdf/MicrodataSchema/SchemaOrgAll.rdf'; } $fileName = $this->getFullFileName($fileName); $rdf = file_get_contents($fileName); if ($rdf) { $this->parseSchema($rdf, $schema); } } } uasort($schema['types'], array($this, 'compareLabels')); uasort($schema['properties'], array($this, 'compareLabels')); // Insert no type and no property entries $languageService = $this->getLanguageService(); $noSchema = $languageService->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No type'); $noProperty = $languageService->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No property'); array_unshift($schema['types'], array('name' => 'none', 'label' => $noSchema)); array_unshift($schema['properties'], array('name' => 'none', 'label' => $noProperty)); // Store json encoded array in temporary file return 'RTEarea[editornumber].schemaUrl = "' . $this->writeTemporaryFile('schema_' . $this->configuration['language'], 'js', json_encode($schema)) . '";'; }
function getElementsData() { $elements_dirname = ADMIN_BASE_PATH.'/components/elements'; if ($elements_dir = opendir($elements_dirname)) { $tmpArray = array(); while (false !== ($dir = readdir($elements_dir))) { if (substr($dir,0,1) != "." && is_dir($elements_dirname . '/' . $dir)) { $tmpKey = strtolower($dir); if (@file_exists($elements_dirname . '/' . $dir . '/metadata.json')) { $tmpValue = json_decode(@file_get_contents($elements_dirname . '/' . $dir . '/metadata.json')); if ($tmpValue) { $tmpArray["$tmpKey"] = $tmpValue; } } } } closedir($elements_dir); if (count($tmpArray)) { return $tmpArray; } else { return false; } } else { echo 'not dir'; return false; } }
function index() { $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS; $files = \GCore\Libs\Folder::getFiles($path, true); $strings = array(); //function to prepare strings $prepare = function ($str) { /*$path = \GCore\C::get('GCORE_FRONT_PATH'); if(strpos($str, $path) !== false AND strpos($str, $path) == 0){ return '//'.str_replace($path, '', $str); }*/ $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : ''; return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";'; }; foreach ($files as $file) { if (substr($file, -4, 4) == '.php') { // AND strpos($file, DS.'extensions'.DS) === TRUE){ //$strings[] = $file; $file_code = file_get_contents($file); preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs); if (!empty($langs[2])) { $strings = array_merge($strings, $langs[2]); } } } $strings = array_unique($strings); $strings = array_map($prepare, $strings); echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>'; }
/** * Upload Image to Imgur * * @param string $image A binary file (path to file), base64 data, or a URL for an image. (up to 10MB) * @param string $type Image type. Use Mechpave\ImgurClient\Model\ImageModel * @param string $title The title of the image * @param string $description The description of the image * @param string $album The id of the album you want to add the image to. For anonymous albums, {album} should be the deletehash that is returned at creation. * @param string $name The name of the file * @throws \UnexpectedValueException * @return ImageInterface */ public function upload($image, $type, $title = null, $description = null, $album = null, $name = null) { if ($type == ImageModel::TYPE_FILE) { //check if file exists and get its contents if (!file_exists($image)) { throw new \UnexpectedValueException('Provided file does not exist'); } $contents = file_get_contents($image); if (!$contents) { throw new \UnexpectedValueException('Could not get file contents'); } $image = $contents; } $postData = ['image' => $image, 'type' => $type]; if ($title) { $postData['title'] = $title; } if ($name) { $postData['name'] = $name; } if ($description) { $postData['description'] = $description; } if ($album) { $postData['album'] = $album; } $response = $this->httpClient->post('image', $postData); $image = $this->imageMapper->buildImage($response->getBody()['data']); return $image; }
function doAction($action) { $id = $_POST['id']; $mapFile = "map/" . $id . ".map"; $offlineFile = "map/offline/" . $id . ".js"; switch ($action) { case "save": if (!is_dir("map")) { mkdir("map"); mkdir("map/offline"); } file_put_contents($mapFile, $_POST['data']); file_put_contents($offlineFile, "Map.level[" . $id . "] = " . $_POST['data']); return $_POST['data']; break; case "load": if (!empty($_POST['offlineMode'])) { return file_get_contents($offlineFile); } if (file_exists($mapFile)) { return file_get_contents($mapFile); } echo "Echo file not found: " . $mapFile; ThrowNotFound(); break; } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { require_once dirname(__FILE__) . '/sfLimeHarness.class.php'; $h = new sfLimeHarness(array('force_colors' => isset($options['color']) && $options['color'], 'verbose' => isset($options['trace']) && $options['trace'])); $h->addPlugins(array_map(array($this->configuration, 'getPluginConfiguration'), $this->configuration->getPlugins())); $h->base_dir = sfConfig::get('sf_test_dir'); $status = false; $statusFile = sfConfig::get('sf_cache_dir') . '/.test_all_status'; if ($options['only-failed']) { if (file_exists($statusFile)) { $status = unserialize(file_get_contents($statusFile)); } } if ($status) { foreach ($status as $file) { $h->register($file); } } else { // filter and register all tests $finder = sfFinder::type('file')->follow_link()->name('*Test.php'); $h->register($this->filterTestFiles($finder->in($h->base_dir), $arguments, $options)); } $ret = $h->run() ? 0 : 1; file_put_contents($statusFile, serialize($h->get_failed_files())); if ($options['xml']) { file_put_contents($options['xml'], $h->to_xml()); } return $ret; }
function getLatandLong($addr, $region) { $url = "http://maps.google.com/maps/api/geocode/json?address=" . $addr . "®ion=" . $region . "&sensor=false"; $response = file_get_contents($url); if ($response == false) { throw new Exception("Failure to obtain data"); } $places = json_decode($response); if (!$places) { throw new Exception("Invalid JSON response"); } if (is_array($places->results) && count($places->results)) { $result = $places->results[0]; $geometry = $result->{'geometry'}; $location = $geometry->{'location'}; $lat = $location->{'lat'}; $long = $location->{'lng'}; ob_start(); // ensures anything dumped out will be caught // do stuff here //header( "Location: $url" ); //return $lat.",".$long; // clear out the output buffer while (ob_get_status()) { ob_end_clean(); } } else { return "Unknown"; } }
/** * Defined by Zend_Filter_Interface * * Decrypts the file $value with the defined settings * * @param string $value Full path of file to change * @return string The filename which has been set, or false when there were errors */ public function filter($value) { if (!file_exists($value)) { //require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception("File '{$value}' not found"); } if (!isset($this->_filename)) { $this->_filename = $value; } if (file_exists($this->_filename) and !is_writable($this->_filename)) { //require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception("File '{$this->_filename}' is not writable"); } $content = file_get_contents($value); if (!$content) { //require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception("Problem while reading file '{$value}'"); } $decrypted = parent::filter($content); $result = file_put_contents($this->_filename, $decrypted); if (!$result) { //require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception("Problem while writing file '{$this->_filename}'"); } return $this->_filename; }
public static function read($file = false) { if (!$file || !file_exists($file)) { return false; } return file_get_contents($file); }
function openxml($filepath, &$error_str = false) { $xmlstr = @file_get_contents($filepath); if ($xmlstr == false) { $error_str = "failed to open file {$filepath}"; return false; } $options = LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_ERR_NONE | LIBXML_COMPACT; $xmldoc = new DOMDocument(); $xmldoc->strictErrorChecking = false; $xmldoc->recover = true; $old = error_reporting(0); $old_libxml = libxml_use_internal_errors(true); $ret = @$xmldoc->loadXml($xmlstr, $options); if ($ret == false) { $error_str = "failed to load xml from {$filepath}"; return false; } $errors = libxml_get_errors(); if (count($errors) > 0) { foreach ($errors as $error) { if ($error->level == LIBXML_ERR_FATAL) { $error_str = "file: {{$filepath}} line: {$error->line} column: {$error->column}: fatal error: {$error->code}: {$error->message}"; return false; } } } $xml = @simplexml_import_dom($xmldoc); error_reporting($old); libxml_use_internal_errors($old_libxml); return $xml; }
function beforeLoad(&$params) { $basePath = JPATH_CONFIGURATION . '/administrator/components/com_jckman/editor/lang'; $languages = JFolder::files($basePath, '.js$', 1, true); $js = ""; $default = $params->get("joomlaLang", "en"); foreach ($languages as $language) { $content = file_get_contents($language); $content = preg_replace("/\\/\\*.*?\\*\\//s", "", $content); $content = str_replace('"', "'", $content); $language = str_replace("\\", "/", $language); $parts = explode("/", $language); $lang = preg_replace("/\\.js\$/", "", array_pop($parts)); $plugin = array_pop($parts); if ($lang != $default && $lang != 'en' || $plugin == 'lang') { //make sure we always load in default english file continue; } $content = preg_replace("/\\)\$/", ");", trim($content)); if ($plugin == 'jflash') { $plug = 'flash'; } else { $plug = $plugin; } $js .= "CKEDITOR.on('" . $plugin . "PluginLoaded', function(evt)\r\n {\r\n editor.lang." . $plug . " = null;\r\n evt.data.lang = ['" . $default . "']; \r\n " . $content . " \r\n });"; } //lets create JS object $javascript = new JCKJavascript(); $javascript->addScriptDeclaration($js); return $javascript->toRaw(); }
/** * @param $list * @param array $ph * @return string */ public function renderJS($list, $ph = array()) { $js = ''; $scripts = MODX_BASE_PATH . $list; if ($this->fs->checkFile($scripts)) { $scripts = @file_get_contents($scripts); $scripts = $this->DLTemplate->parseChunk('@CODE:' . $scripts, $ph); $scripts = json_decode($scripts, true); $scripts = isset($scripts['scripts']) ? $scripts['scripts'] : $scripts['styles']; foreach ($scripts as $name => $params) { if (!isset($this->modx->loadedjscripts[$name])) { if ($this->fs->checkFile($params['src'])) { $this->modx->loadedjscripts[$name] = array('version' => $params['version']); if (end(explode('.', $params['src'])) == 'js') { $js .= '<script type="text/javascript" src="' . $this->modx->config['site_url'] . $params['src'] . '"></script>'; } else { $js .= '<link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . $params['src'] . '">'; } } else { $this->modx->logEvent(0, 3, 'Cannot load ' . $params['src'], $this->customTvName); } } } } else { if ($list == $this->jsListDefault) { $this->modx->logEvent(0, 3, "Cannot load {$this->jsListDefault} .", $this->customTvName); } elseif ($list == $this->cssListDefault) { $this->modx->logEvent(0, 3, "Cannot load {$this->cssListDefault} .", $this->customTvName); } } return $js; }
public static function useConfigurationFile($path) { if (is_readable($path)) { $config = json_decode(file_get_contents($path), true); self::$_cachedConfig = array_merge(self::$_cachedConfig, $config); } }