Skip to content

Commit

Permalink
Исправлен баг в алгоритме "SetPageProperty/SetDirProperty" с og:descr…
Browse files Browse the repository at this point in the history
…iption
  • Loading branch information
darkfriend committed May 29, 2019
1 parent bcf507f commit 4568d5b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
17 changes: 11 additions & 6 deletions utf8/dev2fun.opengraph/classes/general/OpenGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author dev2fun <darkfriend>
* @copyright (c) 2019, darkfriend <[email protected]>
* @version 1.3.0
* @version 1.3.4
*/

namespace Dev2fun\Module;
Expand Down Expand Up @@ -191,10 +191,12 @@ public function saveElement(&$arFields) {
if (is_numeric($file)) {
$reqFields['image'] = $file;
} else {
if (!file_exists($file['tmp_name'])) {
if(empty($file['tmp_name'])) {
$file = \CFile::MakeFileArray($file);
} elseif (!file_exists($file['tmp_name'])) {
$upload_dir = \COption::GetOptionString("main", "upload_dir", "upload");
$absPath = $_SERVER["DOCUMENT_ROOT"] . "/" . $upload_dir . "/tmp";
if (!empty($file['tmp_name']) && !strpos($file['tmp_name'],$absPath)) {
if (!empty($file['tmp_name']) && !strpos($file['tmp_name'], $absPath)) {
$file['tmp_name'] = $absPath . $file['tmp_name'];
}
}
Expand Down Expand Up @@ -263,7 +265,9 @@ public function saveSection(&$arFields) {
if (is_numeric($file)) {
$reqFields['image'] = $file;
} else {
if (!file_exists($file['tmp_name'])) {
if(empty($file['tmp_name'])) {
$file = \CFile::MakeFileArray($file);
} elseif (!file_exists($file['tmp_name'])) {
$upload_dir = \COption::GetOptionString("main", "upload_dir", "upload");
$absPath = $_SERVER["DOCUMENT_ROOT"] . "/" . $upload_dir . "/tmp";
if (!empty($file['tmp_name']) && !strpos($file['tmp_name'],$absPath)) {
Expand Down Expand Up @@ -630,7 +634,8 @@ public function setPropertyPropFields($ogData) {
// print_pre('PropFields');
// break;
case 'og:description' :
$ogValue = $APPLICATION->GetProperty('description');
$ogValue = $APPLICATION->GetProperty('og:description');
if(!$ogValue) $ogValue = $APPLICATION->GetProperty('description');
break;
case 'og:image' :
if (!preg_match('#^(http|https)\:\\\\#', $ogValue)) {
Expand Down Expand Up @@ -677,7 +682,7 @@ public function setPropertyDefault($ogData) {
$url = $oModule->getUrl($APPLICATION->GetCurPage());
$ogValue = $this->getPrepareUrl($url);
break;
case 'site_name' :
case 'og:site_name' :
$obSite = \CSite::GetByID(SITE_ID);
if ($arSite = $obSite->Fetch()) {
$ogValue = htmlentities($arSite['SITE_NAME']);
Expand Down
4 changes: 2 additions & 2 deletions utf8/dev2fun.opengraph/install/version.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$arModuleVersion = array(
"VERSION" => "1.3.3",
"VERSION_DATE" => "2019-03-04 11:00:00",
"VERSION" => "1.3.4",
"VERSION_DATE" => "2019-05-30 10:00:00",
);
?>
17 changes: 11 additions & 6 deletions win1251/dev2fun.opengraph/classes/general/OpenGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author dev2fun <darkfriend>
* @copyright (c) 2019, darkfriend <[email protected]>
* @version 1.3.0
* @version 1.3.4
*/

namespace Dev2fun\Module;
Expand Down Expand Up @@ -191,10 +191,12 @@ public function saveElement(&$arFields) {
if (is_numeric($file)) {
$reqFields['image'] = $file;
} else {
if (!file_exists($file['tmp_name'])) {
if(empty($file['tmp_name'])) {
$file = \CFile::MakeFileArray($file);
} elseif (!file_exists($file['tmp_name'])) {
$upload_dir = \COption::GetOptionString("main", "upload_dir", "upload");
$absPath = $_SERVER["DOCUMENT_ROOT"] . "/" . $upload_dir . "/tmp";
if (!empty($file['tmp_name']) && !strpos($file['tmp_name'],$absPath)) {
if (!empty($file['tmp_name']) && !strpos($file['tmp_name'], $absPath)) {
$file['tmp_name'] = $absPath . $file['tmp_name'];
}
}
Expand Down Expand Up @@ -263,7 +265,9 @@ public function saveSection(&$arFields) {
if (is_numeric($file)) {
$reqFields['image'] = $file;
} else {
if (!file_exists($file['tmp_name'])) {
if(empty($file['tmp_name'])) {
$file = \CFile::MakeFileArray($file);
} elseif (!file_exists($file['tmp_name'])) {
$upload_dir = \COption::GetOptionString("main", "upload_dir", "upload");
$absPath = $_SERVER["DOCUMENT_ROOT"] . "/" . $upload_dir . "/tmp";
if (!empty($file['tmp_name']) && !strpos($file['tmp_name'],$absPath)) {
Expand Down Expand Up @@ -630,7 +634,8 @@ public function setPropertyPropFields($ogData) {
// print_pre('PropFields');
// break;
case 'og:description' :
$ogValue = $APPLICATION->GetProperty('description');
$ogValue = $APPLICATION->GetProperty('og:description');
if(!$ogValue) $ogValue = $APPLICATION->GetProperty('description');
break;
case 'og:image' :
if (!preg_match('#^(http|https)\:\\\\#', $ogValue)) {
Expand Down Expand Up @@ -677,7 +682,7 @@ public function setPropertyDefault($ogData) {
$url = $oModule->getUrl($APPLICATION->GetCurPage());
$ogValue = $this->getPrepareUrl($url);
break;
case 'site_name' :
case 'og:site_name' :
$obSite = \CSite::GetByID(SITE_ID);
if ($arSite = $obSite->Fetch()) {
$ogValue = htmlentities($arSite['SITE_NAME']);
Expand Down
4 changes: 2 additions & 2 deletions win1251/dev2fun.opengraph/install/version.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$arModuleVersion = array(
"VERSION" => "1.3.3",
"VERSION_DATE" => "2019-03-04 11:00:00",
"VERSION" => "1.3.4",
"VERSION_DATE" => "2019-05-30 10:00:00",
);
?>

0 comments on commit 4568d5b

Please sign in to comment.