+ wx.Panel.__init__(self, parent, id)
+ mainSizer = wx.BoxSizer(wx.VERTICAL)
+
+ config = wx.ConfigBase_Get()
+
+ pathLabel = wx.StaticText(self, -1, _("PHP Executable Path:"))
+ path = config.Read("ActiveGridPHPLocation")
+ self._pathTextCtrl = wx.TextCtrl(self, -1, path, size = (150, -1))
+ self._pathTextCtrl.SetToolTipString(self._pathTextCtrl.GetValue())
+ self._pathTextCtrl.SetInsertionPointEnd()
+ choosePathButton = wx.Button(self, -1, _("Browse..."))
+ pathSizer = wx.BoxSizer(wx.HORIZONTAL)
+ HALF_SPACE = 5
+ SPACE = 10
+ pathSizer.Add(pathLabel, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.TOP, HALF_SPACE)
+ pathSizer.Add(self._pathTextCtrl, 1, wx.EXPAND|wx.LEFT|wx.TOP, HALF_SPACE)
+ pathSizer.Add(choosePathButton, 0, wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT|wx.TOP, HALF_SPACE)
+ wx.EVT_BUTTON(self, choosePathButton.GetId(), self.OnChoosePath)
+ mainSizer.Add(pathSizer, 0, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, SPACE)
+
+ iniLabel = wx.StaticText(self, -1, _("php.ini Path:"))
+ ini = config.Read("ActiveGridPHPINILocation")
+ if not ini:
+ if sysutils.isRelease():
+ ini = os.path.normpath(os.path.join(appdirs.getSystemDir(), "php.ini"))
+ else:
+ tmp = self._pathTextCtrl.GetValue().strip()
+ if tmp and len(tmp) > 0:
+ ini = os.path.normpath(os.path.join(os.path.dirname(tmp), "php.ini"))
+
+ self._iniTextCtrl = wx.TextCtrl(self, -1, ini, size = (150, -1))
+ self._iniTextCtrl.SetToolTipString(self._iniTextCtrl.GetValue())
+ self._iniTextCtrl.SetInsertionPointEnd()
+ chooseIniButton = wx.Button(self, -1, _("Browse..."))
+ iniSizer = wx.BoxSizer(wx.HORIZONTAL)
+ HALF_SPACE = 5
+ SPACE = 10
+ iniSizer.Add(iniLabel, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.TOP, HALF_SPACE)
+ iniSizer.Add(self._iniTextCtrl, 1, wx.EXPAND|wx.LEFT|wx.TOP, HALF_SPACE)
+ iniSizer.Add(chooseIniButton, 0, wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT|wx.TOP, HALF_SPACE)
+ wx.EVT_BUTTON(self, chooseIniButton.GetId(), self.OnChooseIni)
+ mainSizer.Add(iniSizer, 0, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, SPACE)
+
+ self._otherOptions = STCTextEditor.TextOptionsPanel(self, -1, configPrefix = "PHP", label = "PHP", hasWordWrap = True, hasTabs = True, addPage=False, hasFolding=False)
+ #STCTextEditor.TextOptionsPanel.__init__(self, parent, id, configPrefix = "PHP", label = "PHP", hasWordWrap = True, hasTabs = True)
+ mainSizer.Add(self._otherOptions, 0, wx.EXPAND|wx.BOTTOM, SPACE)
+
+ self.SetSizer(mainSizer)
+ parent.AddPage(self, _("PHP"))
+
+ def OnChoosePath(self, event):
+ defaultDir = os.path.dirname(self._pathTextCtrl.GetValue().strip())
+ defaultFile = os.path.basename(self._pathTextCtrl.GetValue().strip())
+ if wx.Platform == '__WXMSW__':
+ wildcard = _("Executable (*.exe)|*.exe|All|*.*")
+ if not defaultFile:
+ defaultFile = "php-cgi.exe"
+ else:
+ wildcard = _("*")
+ dlg = wx.FileDialog(wx.GetApp().GetTopWindow(),
+ _("Select a File"),
+ defaultDir=defaultDir,
+ defaultFile=defaultFile,
+ wildcard=wildcard,
+ style=wx.OPEN|wx.FILE_MUST_EXIST|wx.HIDE_READONLY)
+ # dlg.CenterOnParent() # wxBug: caused crash with wx.FileDialog
+ if dlg.ShowModal() == wx.ID_OK:
+ path = dlg.GetPath()
+ if path:
+ self._pathTextCtrl.SetValue(path)
+ self._pathTextCtrl.SetToolTipString(self._pathTextCtrl.GetValue())
+ self._pathTextCtrl.SetInsertionPointEnd()
+ dlg.Destroy()
+
+ def OnChooseIni(self, event):
+ defaultDir = os.path.dirname(self._iniTextCtrl.GetValue().strip())
+ defaultFile = os.path.basename(self._iniTextCtrl.GetValue().strip())
+ if wx.Platform == '__WXMSW__':
+ wildcard = _("Ini (*.ini)|*.ini|All|*.*")
+ if not defaultFile:
+ defaultFile = "php.ini"
+ else:
+ wildcard = _("*")
+ dlg = wx.FileDialog(wx.GetApp().GetTopWindow(),
+ _("Select a File"),
+ defaultDir=defaultDir,
+ defaultFile=defaultFile,
+ wildcard=wildcard,
+ style=wx.OPEN|wx.FILE_MUST_EXIST|wx.HIDE_READONLY)
+ # dlg.CenterOnParent() # wxBug: caused crash with wx.FileDialog
+ if dlg.ShowModal() == wx.ID_OK:
+ ini = dlg.GetPath()
+ if ini:
+ self._iniTextCtrl.SetValue(ini)
+ self._iniTextCtrl.SetToolTipString(self._iniTextCtrl.GetValue())
+ self._iniTextCtrl.SetInsertionPointEnd()
+ dlg.Destroy()
+
+ def OnOK(self, optionsDialog):
+ config = wx.ConfigBase_Get()
+ config.Write("ActiveGridPHPLocation", self._pathTextCtrl.GetValue().strip())
+ config.Write("ActiveGridPHPINILocation", self._iniTextCtrl.GetValue().strip())
+
+ self._otherOptions.OnOK(optionsDialog)
+
+ def GetIcon(self):
+ return getPHPIcon()