1818use Joomla \CMS \Language \Text ;
1919use Joomla \CMS \MVC \View \GenericDataException ;
2020use Joomla \CMS \MVC \View \HtmlView as BaseHtmlView ;
21+ use Joomla \Component \Weblinks \Site \Model \FormModel ;
2122
2223/**
2324 * HTML Article View class for the Weblinks component
@@ -74,10 +75,18 @@ public function display($tpl = null)
7475 $ user = $ this ->getCurrentUser ();
7576
7677 // Get model data.
77- $ this ->state = $ this ->get ('State ' );
78- $ this ->item = $ this ->get ('Item ' );
79- $ this ->form = $ this ->get ('Form ' );
80- $ this ->return_page = $ this ->get ('ReturnPage ' );
78+ /* @var FormModel $model */
79+ $ model = $ this ->getModel ();
80+
81+ $ this ->state = $ model ->getState ();
82+ $ this ->item = $ model ->getItem ();
83+ $ this ->form = $ model ->getForm ();
84+ $ this ->return_page = $ model ->getReturnPage ();
85+
86+ // Check for errors.
87+ if (\count ($ errors = $ model ->getErrors ())) {
88+ throw new GenericDataException (implode ("\n" , $ errors ), 500 );
89+ }
8190
8291 if (empty ($ this ->item ->id )) {
8392 $ authorised = $ user ->authorise ('core.create ' , 'com_weblinks ' ) || \count ($ user ->getAuthorisedCategories ('com_weblinks ' , 'core.create ' ));
@@ -100,11 +109,6 @@ public function display($tpl = null)
100109 $ this ->form ->bind ($ this ->item );
101110 }
102111
103- // Check for errors.
104- if (\count ($ errors = $ this ->get ('Errors ' ))) {
105- throw new GenericDataException (implode ("\n" , $ errors ), 500 );
106- }
107-
108112 // Create a shortcut to the parameters.
109113 $ params = &$ this ->state ->params ;
110114
@@ -126,11 +130,9 @@ public function display($tpl = null)
126130 */
127131 protected function prepareDocument ()
128132 {
129- $ app = Factory::getApplication ();
130-
131133 // Because the application sets a default page title,
132134 // we need to get it from the menu item itself
133- $ menu = $ app ->getMenu ()->getActive ();
135+ $ menu = Factory:: getApplication () ->getMenu ()->getActive ();
134136
135137 if (empty ($ this ->item ->id )) {
136138 $ head = Text::_ ('COM_WEBLINKS_FORM_SUBMIT_WEBLINK ' );
@@ -149,15 +151,15 @@ protected function prepareDocument()
149151 $ this ->setDocumentTitle ($ title );
150152
151153 if ($ this ->params ->get ('menu-meta_description ' )) {
152- $ this ->document ->setDescription ($ this ->params ->get ('menu-meta_description ' ));
154+ $ this ->getDocument () ->setDescription ($ this ->params ->get ('menu-meta_description ' ));
153155 }
154156
155157 if ($ this ->params ->get ('menu-meta_keywords ' )) {
156- $ this ->document ->setMetadata ('keywords ' , $ this ->params ->get ('menu-meta_keywords ' ));
158+ $ this ->getDocument () ->setMetadata ('keywords ' , $ this ->params ->get ('menu-meta_keywords ' ));
157159 }
158160
159161 if ($ this ->params ->get ('robots ' )) {
160- $ this ->document ->setMetadata ('robots ' , $ this ->params ->get ('robots ' ));
162+ $ this ->getDocument () ->setMetadata ('robots ' , $ this ->params ->get ('robots ' ));
161163 }
162164 }
163165}
0 commit comments