
Öffentliche Methoden | |
| preDispatch () | |
| Modell und Session initialisieren. | |
| deleteAction () | |
| Löscht Text mit übergebener ID. | |
| editAction () | |
| Editieren vorhandener Texte. | |
| insertAction () | |
| Fuegt neuen Text zu aktuellem Abenteuer hinzu. | |
| showAction () | |
| Zeigt den Spieltisch oder laedt ueber Ajax Texte nach. | |
Geschützte Attribute | |
| $_namespaceGameDesk = null | |
| Zend_Session_Namespace, Sessionnamensbereich des Spieltisches. | |
Definiert in Zeile 9 der Datei DeskController.php.
| Game_DeskController::deleteAction | ( | ) |
Löscht Text mit übergebener ID.
Löscht Text mit übergebener ID, sofern der Benutzer die Erlaubnis hat.
Definiert in Zeile 48 der Datei DeskController.php.
Benutzt Dsao_Controller_Action::_getModel(), Dsao_Controller_Action::getHelper(), Dsao_Controller_Action::getLog(), Dsao_Controller_Action::getUri(), Dsao_Controller_Action::getUser(), Dsao_Controller_Action::getView() und Dsao_Controller_Action::isXmlHttpRequest().
00049 { 00050 // Token 00051 if (!$this->getHelper('SessionToken')->hasValidToken()) 00052 { 00053 return; 00054 } 00055 00056 $idText = $this->getUri()->id; 00057 00058 // Falls keine Ajax-Anfrage 00059 if(!$this->isXmlHttpRequest()) 00060 { 00061 // Falls Benutzer das Loeschen noch nicht bestaetigt hat 00062 if (!$this->getUri()->confirmation) 00063 { 00064 // Bestätigungstemplate anzeigen 00065 $this->getView()->addConfirmationTemplate( 00066 'game_desk_delete_confirmation', 00067 '/game/desk/delete/id/'.$idText.'/confirmation/1'); 00068 00069 return true; 00070 } 00071 00072 // Einbinden von Template verhindern 00073 $this->getView()->addTemplate(false); 00074 } 00075 00076 // Falls Text geloescht werden konnte 00077 if ($this->_getModel()->deleteText($this->getUser()->getId(), $idText)) 00078 { 00079 // Falls Ajax-Anfrage 00080 if ($this->isXmlHttpRequest()) 00081 { 00082 // ID uebergeben 00083 $this->getView()->assign('idText', $idText); 00084 00085 return true; 00086 } 00087 00088 // Bestaetigung 00089 $this->getLog()->affirm('game_desk_delete_affirmation_deleted'); 00090 00091 return true; 00092 } 00093 00094 // Fehlermeldung ausgeben 00095 $this->getLog()->err('game_desk_delete_error_permission_denied'); 00096 00097 return false; 00098 }
| Game_DeskController::editAction | ( | ) |
Editieren vorhandener Texte.
Definiert in Zeile 105 der Datei DeskController.php.
Benutzt Dsao_Controller_Action::_getModel(), Dsao_Controller_Action::getHelper(), Dsao_Controller_Action::getLog(), Dsao_Controller_Action::getUri(), Dsao_Controller_Action::getUser(), Dsao_Controller_Action::getView(), Dsao_Controller_Action::isXmlHttpRequest() und Dsao_Ajax_Response::PLAIN.
00106 { 00107 // int, ID des zu bearbeitenden Textes 00108 $idText = $this->getUri()->id; 00109 00110 // Falls der Benutzer keine Berechtigung hat, auf ID zuzugreifen 00111 if (!$rowText = $this->_getModel()->hasChangePermission 00112 ($this->getUser()->getId(), $idText)) 00113 { 00114 // Fehlermeldung ausgeben. 00115 $this->getLog()->err('game_desk_edit_error_permission_denied'); 00116 $this->getView()->addTemplate(false); 00117 00118 return false; 00119 } 00120 00121 // Falls Formular noch nicht abgeschickt wurde 00122 if (!$this->getRequest()->isPost()) 00123 { 00124 $rowTextContent = $rowText->content; 00125 00126 // Fuer Ajax muss Zeile dekodiert werden 00127 if ($this->isXmlHttpRequest()) 00128 { 00129 $rowTextArray = $rowText->toArrayDecoded(); 00130 00131 $rowTextContent = $rowTextArray['content']; 00132 } 00133 00134 $this->getView()->assign(array( 00135 'gameDeskEditContent' => $rowTextContent, 00136 'idText' => $idText 00137 )); 00138 00139 return true; 00140 } 00141 00142 // Token 00143 if (!$this->getHelper('SessionToken')->hasValidToken()) 00144 { 00145 return; 00146 } 00147 00148 // Text editieren 00149 $this->_getModel()->editText($this->getUser(), $idText, 00150 $this->getRequest()->getPost('content')); 00151 00152 // Falls Inhalt vorhanden 00153 if ($this->getRequest()->getPost('content')) 00154 { 00155 // Falls Ajax-Anfrage, den Inhalt zurueckgeben 00156 if ($this->isXmlHttpRequest()) 00157 { 00158 // Zeile aktualisieren und dekodieren 00159 $rowText->refresh(); 00160 $rowTextArray = $rowText->toArrayDecoded(); 00161 00162 // Inhalt uebergeben. 00163 $this->getView()->getAjaxResponse()->setData 00164 ($rowTextArray['content'] , Dsao_Ajax_Response::PLAIN); 00165 } 00166 00167 $this->getLog()->affirm('game_desk_edit_affirmation_edited'); 00168 } 00169 // Ansonsten ist Text geloescht worden 00170 else 00171 { 00172 $this->getLog()->affirm('game_desk_delete_affirmation_deleted'); 00173 } 00174 00175 $this->getView()->addTemplate(false); 00176 00177 return true; 00178 }
| Game_DeskController::insertAction | ( | ) |
Fuegt neuen Text zu aktuellem Abenteuer hinzu.
Definiert in Zeile 185 der Datei DeskController.php.
Benutzt Dsao_Controller_Action::_getModel(), Dsao_Controller_Action::_gotoSimple(), Dsao_Controller_Action::getHelper(), Dsao_Controller_Action::getUser(), Dsao_Controller_Action::isXmlHttpRequest() und showAction().
00186 { 00187 // Token 00188 if (!$this->getHelper('SessionToken')->hasValidToken()) 00189 { 00190 return; 00191 } 00192 00193 $this->_getModel()->insertText(1, $this->getUser()->username, 00194 $this->getRequest()->getPost('content')); 00195 00196 // Falls keine Ajax-Anfrage 00197 if (!$this->isXmlHttpRequest()) 00198 { 00199 $this->_gotoSimple('show'); 00200 00201 return true; 00202 } 00203 00204 // Texte laden 00205 $this->showAction(); 00206 00207 return true; 00208 }
| Game_DeskController::preDispatch | ( | ) |
Modell und Session initialisieren.
Erneute Implementation von Dsao_Controller_Action.
Definiert in Zeile 21 der Datei DeskController.php.
Benutzt Dsao_Controller_Action::_getModel() und Dsao_Controller_Action::_setDefaultModelClass().
00022 { 00023 // Standardmodellklasse 00024 $this->_setDefaultModelClass('Game_Desk'); 00025 00026 // Falls Seite zum ersten Mal aufgerufen wurde, Session initialisieren 00027 if (!Zend_Session::namespaceIsset('game_desk')) 00028 { 00029 $this->_namespaceGameDesk = new Zend_Session_Namespace('game_desk'); 00030 $this->_namespaceGameDesk->lastRefresh = time()-60*60*24*7; 00031 } 00032 else 00033 { 00034 $this->_namespaceGameDesk = new Zend_Session_Namespace('game_desk'); 00035 } 00036 00037 // Ggf. Aufraeumaktion durchfuehren -> leere Zeilen werden geloescht 00038 $this->_getModel()->deleteEmptyRows(); 00039 }
| Game_DeskController::showAction | ( | ) |
Zeigt den Spieltisch oder laedt ueber Ajax Texte nach.
Definiert in Zeile 215 der Datei DeskController.php.
Benutzt Dsao_Controller_Action::_addJsFile(), Dsao_Controller_Action::_getModel(), Dsao_Controller_Action::getHelper(), Dsao_Controller_Action::getTranslate(), Dsao_Controller_Action::getView() und Dsao_Controller_Action::isXmlHttpRequest().
Wird benutzt von insertAction().
00216 { 00217 // Falls es eine Ajax-Anfrage ist 00218 if ($this->isXmlHttpRequest()) 00219 { 00220 $this->getView()->assign('texts', $this->_getModel()->fetchGroupTexts 00221 (1, $this->_namespaceGameDesk->lastRefresh, true)->toArrayDecoded()); 00222 00223 // Session aktualisieren 00224 $this->_namespaceGameDesk->lastRefresh = time(); 00225 00226 return true; 00227 } 00228 // Zur History hinzufügen 00229 else 00230 { 00231 $this->getHelper('History')->setAddToHistory(); 00232 } 00233 00234 // array, Geladene Texte 00235 $loadedTexts = $this->_getModel()->fetchGroupTexts 00236 (1, time()-60*60*24*7)->toArrayDecoded(); 00237 00238 // Session aktualisieren 00239 $this->_namespaceGameDesk->lastRefresh = time(); 00240 00241 // Systemeintrag 00242 $loadedTexts[] = array 00243 ( 00244 'author' => 'System', 00245 'content' => $this->getTranslate()-> 00246 _('game_desk_show_info_no_texts'), 00247 'id' => 'system', 00248 'lastEditedBy' => 'System', 00249 'timeCreated' => date('d.m.y - H:i:s'), 00250 'timeLastEdited'=> date('d.m.y - H:i:s'), 00251 ); 00252 00253 $this->getView()->assign_by_ref('gameDeskTexts', $loadedTexts); 00254 00255 // Scriptaculous laden 00256 $this->getView()->addScriptaculousFiles(array('effects', 'controls')); 00257 00258 // JS-Datei hinzufuegen 00259 $this->_addJsFile(); 00260 00261 // JS-Texte hinzufuegen 00262 $this->getView()->addJsTexts(array 00263 ( 00264 'game_desk_delete_confirmation', 00265 'game_desk_edit_js_cancel_template', 00266 'game_desk_edit_js_loading_template', 00267 'game_desk_edit_js_saving_template', 00268 'game_desk_edit_js_submit_template' 00269 )); 00270 00271 return true; 00272 }
1.5.7.1