Browse Source

#24 - Minor fixes and improvements.

AntonLV 12 năm trước cách đây
mục cha
commit
22f7f2772a

+ 11 - 6
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -463,14 +463,19 @@ class BxTimelineModule extends BxBaseModNotificationsModule
             $sLink = $oForm->getCleanValue('url');
             $sLinkContent = bx_file_get_contents($sLink);
 
-            $aMatch = array();
-            preg_match($this->_oConfig->getPregPattern('meta_title'), $sLinkContent, $aMatch);
-            $sLinkTitle = $aMatch ? $aMatch[1] : '';
+            $aMatches = array();
+            preg_match($this->_oConfig->getPregPattern('url'), $sLink, $aMatches);
+            $sLink = (empty($aMatches[1]) ? 'http://' : '') . $aMatches[0];
 
-            preg_match($this->_oConfig->getPregPattern('meta_description'), $sLinkContent, $aMatch);
-            $sLinkDescription = $aMatch ? $aMatch[1] : '';
+            $aMatches = array();
+            preg_match($this->_oConfig->getPregPattern('meta_title'), $sLinkContent, $aMatches);
+            $sLinkTitle = $aMatches ? $aMatches[1] : '';
 
-            $iId = (int)$oForm->insert(array('profile_id' => $iUserId, 'title' => $sLinkTitle, 'text' => $sLinkDescription, 'added' => time()));
+            $aMatches = array();
+            preg_match($this->_oConfig->getPregPattern('meta_description'), $sLinkContent, $aMatches);
+            $sLinkDescription = $aMatches ? $aMatches[1] : '';
+
+            $iId = (int)$oForm->insert(array('profile_id' => $iUserId, 'url' => $sLink, 'title' => $sLinkTitle, 'text' => $sLinkDescription, 'added' => time()));
             if(!empty($iId))
                 return array('item' => $this->_oTemplate->getAttachLinkItem($iUserId, $iId));
 

+ 1 - 1
modules/boonex/timeline/install/sql/install.sql

@@ -268,7 +268,7 @@ INSERT INTO `sys_form_displays` (`display_name`, `module`, `object`, `title`, `v
 ('bx_timeline_attach_link_add', @sName, 'bx_timeline_attach_link', '_bx_timeline_form_attach_link_display_add', 0);
 
 INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `checked`, `type`, `caption_system`, `caption`, `info`, `required`, `collapsed`, `html`, `attrs`, `attrs_tr`, `attrs_wrapper`, `checker_func`, `checker_params`, `checker_error`, `db_pass`, `db_params`, `editable`, `deletable`) VALUES
-('bx_timeline_attach_link', @sName, 'url', '', '', 0, 'text', '_bx_timeline_form_attach_link_input_sys_url', '_bx_timeline_form_attach_link_input_url', '', 0, 0, 0, '', '', '', 'Preg', 'a:1:{s:4:"preg";s:0:"";}', '_bx_timeline_form_attach_link_input_url_err', 'Xss', '', 0, 0),
+('bx_timeline_attach_link', @sName, 'url', '', '', 0, 'text', '_bx_timeline_form_attach_link_input_sys_url', '_bx_timeline_form_attach_link_input_url', '', 0, 0, 0, '', '', '', 'Preg', 'a:1:{s:4:"preg";s:0:"";}', '_bx_timeline_form_attach_link_input_url_err', '', '', 0, 0),
 ('bx_timeline_attach_link', @sName, 'controls', '', 'do_submit,do_cancel', 0, 'input_set', '', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
 ('bx_timeline_attach_link', @sName, 'do_submit', '_bx_timeline_form_attach_link_input_do_submit', '', 0, 'submit', '_bx_timeline_form_attach_link_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
 ('bx_timeline_attach_link', @sName, 'do_cancel', '_bx_timeline_form_attach_link_input_do_cancel', '', 0, 'button', '_bx_timeline_form_attach_link_input_do_cancel', '', '', 0, 0, 0, 'a:2:{s:7:"onclick";s:45:"$(''.bx-popup-applied:visible'').dolPopupHide()";s:5:"class";s:22:"bx-def-margin-sec-left";}', '', '', '', '', '', '', '', 0, 0);