本文整理汇总了PHP中Pimcore_Tool::getHttpData方法的典型用法代码示例。如果您正苦于以下问题:PHP Pimcore_Tool::getHttpData方法的具体用法?PHP Pimcore_Tool::getHttpData怎么用?PHP Pimcore_Tool::getHttpData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore_Tool
的用法示例。
在下文中一共展示了Pimcore_Tool::getHttpData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUpdateInformationAction
public function getUpdateInformationAction()
{
$id = $this->_getParam("id");
$type = $this->_getParam("type");
if ($type == "plugin") {
$extensionPath = PIMCORE_PLUGINS_PATH . "/" . $id;
} else {
if ($type = "brick") {
$extensionPath = PIMCORE_WEBSITE_PATH . "/var/areas/" . $id;
}
}
$remoteConfig = array("token" => Pimcore_Liveconnect::getToken(), "id" => $id, "type" => $type, "revision" => trim(file_get_contents($extensionPath . "/.pimcore_extension_revision")));
$rawData = Pimcore_Tool::getHttpData("http://extensions.pimcore.org/update/getUpdateInformation.php", null, array("data" => base64_encode(serialize($remoteConfig))));
if (!$rawData) {
header('HTTP/1.1 403 Forbidden');
exit;
}
$steps = array();
$numberOfFiles = 0;
$data = Zend_Json::decode($rawData);
foreach ($data["revisions"] as $revision) {
foreach ($revision["files"] as $file) {
$steps[] = array("action" => $file["action"], "controller" => "download", "params" => array("id" => $id, "type" => $type, "path" => $file["path"], "revision" => $file["revision"]));
$numberOfFiles++;
}
$steps[] = array("action" => "check-update-script", "controller" => "update", "params" => array("id" => $id, "type" => $type, "revision" => $revision["revision"]));
}
$this->_helper->json(array("steps" => $steps, "fileAmount" => $numberOfFiles));
}
示例2: getLanguagesAction
public function getLanguagesAction()
{
$languagesJson = Pimcore_Tool::getHttpData("http://www.pimcore.org/community/translations/pimcore_download");
echo $languagesJson;
exit;
$languagesData = Zend_Json_Decoder::decode($languagesJson);
$languages = $languagesData["languages"];
if (is_array($languages)) {
for ($i = 0; $i < count($languages); $i++) {
if (is_file($filesDir = PIMCORE_WEBSITE_PATH . "/var/config/texts/" . $languages[$i]['key'] . ".csv")) {
$languages[$i]["exists"] = true;
} else {
$languages[$i]["exists"] = false;
}
}
}
$this->_helper->json(array("languages" => $languages));
}
示例3: getExtensionsAction
public function getExtensionsAction()
{
$configurations = array();
// plugins
$pluginConfigs = Pimcore_ExtensionManager::getPluginConfigs();
// get remote repo state of plugins
$remoteConfig = array();
foreach ($pluginConfigs as $config) {
if (!is_file(Pimcore_ExtensionManager::getPathForExtension($config["plugin"]["pluginName"], "plugin") . "/.pimcore_extension_revision")) {
$remoteConfig["extensions"][] = array("id" => $config["plugin"]["pluginName"], "type" => "plugin");
}
}
$brickConfigs = Pimcore_ExtensionManager::getBrickConfigs();
// get repo state of bricks
foreach ($brickConfigs as $id => $config) {
if (!is_file(Pimcore_ExtensionManager::getPathForExtension($id, "brick") . "/.pimcore_extension_revision")) {
$remoteConfig["extensions"][] = array("id" => $id, "type" => "brick");
}
}
$remoteConfig["token"] = Pimcore_Liveconnect::getToken();
$rawData = Pimcore_Tool::getHttpData("http://extensions.pimcore.org/share/getExtensions.php", null, array("data" => base64_encode(Pimcore_Tool_Serialize::serialize($remoteConfig))));
if (!$rawData) {
header('HTTP/1.1 403 Forbidden');
exit;
}
$hubInfos = Zend_Json::decode($rawData);
// create configuration for plugins
foreach ($pluginConfigs as $config) {
$plugin = array("id" => $config["plugin"]["pluginName"], "type" => "plugin", "name" => $config["plugin"]["pluginNiceName"], "description" => $config["plugin"]["pluginDescription"], "icon" => $config["plugin"]["pluginIcon"], "exists" => (bool) $hubInfos["extensions"][$config["plugin"]["pluginName"]]["existing"]);
if ($hubInfos["extensions"][$plugin["id"]]["allowed"]) {
$configurations[] = $plugin;
}
}
// create configuration for bricks
foreach ($brickConfigs as $id => $config) {
$brick = array("id" => $id, "type" => "brick", "name" => $config->name, "description" => $config->description, "exists" => (bool) $hubInfos["extensions"][$id]["existing"]);
if ($hubInfos["extensions"][$id]["allowed"]) {
$configurations[] = $brick;
}
}
$this->_helper->json(array("extensions" => $configurations));
}
示例4: downloadFileAction
public function downloadFileAction()
{
$id = $this->_getParam("id");
$type = $this->_getParam("type");
$path = $this->_getParam("path");
$revision = $this->_getParam("revision");
$remoteConfig = $this->_getAllParams();
$remoteConfig["token"] = Pimcore_Liveconnect::getToken();
$rawData = Pimcore_Tool::getHttpData("http://extensions.pimcore.org/download/downloadFile.php?data=" . base64_encode(serialize($remoteConfig)));
if (!$rawData) {
header('HTTP/1.1 403 Forbidden');
exit;
}
$file = Zend_Json::decode($rawData);
if ($type == "plugin") {
$parentPath = PIMCORE_PLUGINS_PATH;
} else {
if ($type == "brick") {
$parentPath = PIMCORE_WEBSITE_PATH . "/var/areas";
}
}
if (!is_dir($parentPath)) {
mkdir($parentPath, 0755, true);
}
$fileDestPath = $parentPath . $path;
if (!is_dir(dirname($fileDestPath))) {
mkdir(dirname($fileDestPath), 0755, true);
}
file_put_contents($fileDestPath, base64_decode($file["content"]));
chmod($fileDestPath, 0766);
// write revision information
$revisionFile = $parentPath . "/" . $id . "/.pimcore_extension_revision";
file_put_contents($revisionFile, $revision);
chmod($revisionFile, 0766);
$this->_helper->json(array("success" => true));
}
示例5: saveImagePixlrAction
public function saveImagePixlrAction()
{
$asset = Asset::getById($this->_getParam("id"));
$asset->setData(Pimcore_Tool::getHttpData($this->_getParam("image")));
$asset->setUserModification($this->getUser()->getId());
$asset->save();
$this->view->asset = $asset;
}
示例6: seopanelTreeAction
public function seopanelTreeAction()
{
$document = Document::getById($this->_getParam("node"));
$documents = array();
if ($document->hasChilds()) {
$list = new Document_List();
$list->setCondition("parentId = ?", $document->getId());
$list->setOrderKey("index");
$list->setOrder("asc");
$childsList = $list->load();
foreach ($childsList as $childDocument) {
// only display document if listing is allowed for the current user
if ($childDocument->isAllowed("list")) {
$list = new Document_List();
$list->setCondition("path LIKE ? and type = ?", array($childDocument->getFullPath() . "/%", "page"));
if ($childDocument instanceof Document_Page || $list->getTotalCount() > 0) {
$nodeConfig = $this->getTreeNodeConfig($childDocument);
if (method_exists($childDocument, "getTitle") && method_exists($childDocument, "getDescription")) {
$nodeConfig["title"] = $childDocument->getTitle();
$nodeConfig["description"] = $childDocument->getDescription();
$nodeConfig["title_length"] = strlen($childDocument->getTitle());
$nodeConfig["description_length"] = strlen($childDocument->getDescription());
// anaylze content
$nodeConfig["links"] = 0;
$nodeConfig["externallinks"] = 0;
$nodeConfig["h1"] = 0;
$nodeConfig["h1_text"] = "";
$nodeConfig["hx"] = 0;
$nodeConfig["imgwithalt"] = 0;
$nodeConfig["imgwithoutalt"] = 0;
try {
// cannot use the rendering service from Document_Service::render() because of singleton's ...
// $content = Document_Service::render($childDocument, array("pimcore_admin" => true, "pimcore_preview" => true), true);
$request = $this->getRequest();
$contentUrl = $request->getScheme() . "://" . $request->getHttpHost() . $childDocument->getFullPath();
$content = Pimcore_Tool::getHttpData($contentUrl, array("pimcore_preview" => true, "pimcore_admin" => true, "_dc" => time()));
if ($content) {
$html = str_get_html($content);
if ($html) {
$nodeConfig["links"] = count($html->find("a"));
$nodeConfig["externallinks"] = count($html->find("a[href^=http]"));
$nodeConfig["h1"] = count($html->find("h1"));
$h1 = $html->find("h1", 0);
if ($h1) {
$nodeConfig["h1_text"] = strip_tags($h1->innertext);
}
$nodeConfig["hx"] = count($html->find("h2,h2,h4,h5"));
$images = $html->find("img");
if ($images) {
foreach ($images as $image) {
$alt = $image->alt;
if (empty($alt)) {
$nodeConfig["imgwithoutalt"]++;
} else {
$nodeConfig["imgwithalt"]++;
}
}
}
}
}
} catch (Exception $e) {
Logger::debug($e);
}
if (strlen($childDocument->getTitle()) > 80 || strlen($childDocument->getTitle()) < 5 || strlen($childDocument->getDescription()) > 180 || strlen($childDocument->getDescription()) < 20 || $nodeConfig["h1"] != 1 || $nodeConfig["hx"] < 1) {
$nodeConfig["cls"] = "pimcore_document_seo_warning";
}
}
$documents[] = $nodeConfig;
}
}
}
}
$this->_helper->json($documents);
}
示例7: translateAction
public function translateAction()
{
$conf = Pimcore_Config::getSystemConfig();
$key = $conf->services->translate->apikey;
$locale = new Zend_Locale($this->_getParam("language"));
$language = $locale->getLanguage();
$supportedTypes = array("input", "textarea", "wysiwyg");
$data = Zend_Json::decode($this->_getParam("data"));
foreach ($data as &$d) {
if (in_array($d["type"], $supportedTypes)) {
$response = Pimcore_Tool::getHttpData("https://www.googleapis.com/language/translate/v2?key=" . $key . "&q=" . urlencode($d["data"]) . "&target=" . $language);
$tData = Zend_Json::decode($response);
if ($tData["data"]["translations"][0]["translatedText"]) {
$d["data"] = $tData["data"]["translations"][0]["translatedText"];
}
}
}
$this->getRequest()->setParam("data", Zend_Json::encode($data));
$this->saveToSessionAction();
}
示例8: downloadLanguage
/**
* Download language files for a specific language for pimcore core and all plugins or
* download language files for all existing system languages for pimcore core and plugins if parameter is null
* @static
* @param $language
* @return bool
*/
public static function downloadLanguage($lang = null)
{
$languages = Pimcore_Tool_Admin::getLanguages();
if (!empty($lang)) {
$languages = array($lang);
} else {
//omit core language
$additonalLanguages = array();
foreach ($languages as $lang) {
if ($lang != "en") {
$additonalLanguages[] = $lang;
}
}
$languages = $additonalLanguages;
}
//directory for additional languages
$langDir = PIMCORE_WEBSITE_PATH . "/var/config/texts";
if (!is_dir($langDir)) {
mkdir($langDir, 0755, true);
}
$success = is_dir($langDir);
if ($success) {
if (is_array($languages)) {
foreach ($languages as $language) {
//TODO: remove hard coded
$src = "http://www.pimcore.org/?controller=translation&action=download&language=" . $language;
$data = Pimcore_Tool::getHttpData($src);
if (!empty($language) and !empty($data)) {
try {
$languageFile = $langDir . "/" . $language . ".csv";
$fh = fopen($languageFile, 'w');
fwrite($fh, $data);
fclose($fh);
} catch (Exception $e) {
Logger::error("could not download language file");
Logger::error($e);
$success = false;
}
}
}
}
} else {
Logger::warning("Pimcore_Update: Could not create language dir [ {$langDir} ]");
}
return $success;
}