00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00040 class CreateEmailMessageFromRelatedListLinkActionElement extends RelatedListLinkActionElement
00041 {
00042 public function render()
00043 {
00044 return ZurmoHtml::ajaxLink($this->getLabel(), $this->getDefaultRoute(),
00045 $this->getAjaxLinkOptions(),
00046 $this->getHtmlOptions()
00047 );
00048 }
00049
00050 public function renderMenuItem()
00051 {
00052 return array('label' => $this->getLabel(),
00053 'url' => $this->getDefaultRoute(),
00054 'linkOptions' => $this->getHtmlOptions(),
00055 'ajaxLinkOptions' => $this->getAjaxLinkOptions()
00056 );
00057 }
00058
00059 protected function getHtmlOptions()
00060 {
00061 $htmlOptions = parent::getHtmlOptions();
00062 $this->resolveHtmlOptionsId($htmlOptions);
00063 return $htmlOptions;
00064 }
00065
00066 protected function resolveHtmlOptionsId(& $htmlOptions)
00067 {
00068 if ($this->getLinkId() != null)
00069 {
00070 $htmlOptions['id'] = $this->getLinkId();
00071 }
00072 }
00073
00074 protected function getAjaxLinkOptions()
00075 {
00076 $title = Zurmo::t('EmailMessagesModule', 'Email');
00077 return ModalView::getAjaxOptionsForModalLink(
00078 Zurmo::t('EmailMessagesModule', 'Compose Email'), 'modalContainer', 'auto', 800,
00079 array(
00080 'my' => 'top',
00081 'at' => 'bottom',
00082 'of' => '#HeaderView'));
00083 }
00084
00085 protected function getDefaultLabel()
00086 {
00087 return Zurmo::t('EmailMessagesModule', 'Email');
00088 }
00089
00090 protected function getDefaultRoute()
00091 {
00092 return Yii::app()->createUrl('/emailMessages/default/createEmailMessage', $this->resolveRouteParamters());
00093 }
00094
00099 protected function resolveRouteParamters()
00100 {
00101 $routeParameters = $this->getRouteParameters();
00102 if (!isset($routeParameters['relatedId']))
00103 {
00104 $routeParameters['relatedId'] = $this->modelId;
00105 }
00106 return $routeParameters;
00107 }
00108
00109 public function getActionType()
00110 {
00111 return 'Create';
00112 }
00113
00114 protected function getGridId()
00115 {
00116 if (!isset($this->params['gridId']))
00117 {
00118 return null;
00119 }
00120 return $this->params['gridId'];
00121 }
00122
00123 protected function getLinkId()
00124 {
00125 if ($this->getGridId() == null)
00126 {
00127 return null;
00128 }
00129 return $this->getGridId(). '-createEmail-' . $this->modelId;
00130 }
00131 }
00132 ?>