Пример #1
0
 /**
  * Add the page title and toolbar.
  *
  * @return  void
  */
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $name = $this->getName();
     $doc = JFactory::getDocument();
     if (file_exists(JPATH_BASE . '/media/babioon/images/icon-48-babioon-' . $name . '.png')) {
         $doc->addStyleDeclaration('.icon-48-babioon-' . $name . ' {background-image: url(../media/babioon/images/icon-48-babioon-' . $name . '.png);}');
         $image = 'babioon-' . $name . '.png';
     } else {
         $doc->addStyleDeclaration('.icon-48-babioon {background-image: url(../media/babioon/images/icon-48-babioon.png);}');
         $image = 'babioon.png';
     }
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
     $canDo = BabioonAdHelper::getActions($name);
     $tag = 'COM_BABIOONAD_' . strtoupper($name);
     JToolBarHelper::title($isNew ? JText::_($tag . '_NEW') : JText::_($tag . '_EDIT'), $image);
     // If not checked out, can save the item.
     if (!$checkedOut && $canDo->get('core.edit')) {
         JToolBarHelper::apply($name . '.apply');
         JToolBarHelper::save($name . '.save');
     }
     JToolBarHelper::cancel($name . '.cancel', 'JTOOLBAR_CLOSE');
 }
Пример #2
0
 /**
  * [display description]
  *
  * @param   [type]  $tpl  [description]
  *
  * @return  [type]        [description]
  */
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu();
     $activeitem = $menus->getActive();
     $this->menuname = $activeitem->name;
     $this->mparams = new JParameter($activeitem->params);
     // Check if we get a vaild id
     $id = JRequest::getVar('id', 0);
     $result = BabioonAdHelper::checkId($id);
     if ($result === false) {
         $this->displayOutOfRage();
         return;
     }
     $this->id = $id;
     if ($this->getLayout() == 'submitpage') {
         $this->displaySubmitPage($tpl);
         return;
     }
     if ($this->getLayout() == 'submit') {
         $this->displaySubmit($tpl);
         return;
     }
     $this->setLayout('form');
     if ($this->getLayout() == 'form') {
         $this->displayForm($tpl);
         return;
     }
     return;
 }
Пример #3
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  */
 protected function addToolbar()
 {
     $name = $this->getName();
     $tag = strtoupper($name);
     $singular = BabioonAdHelper::toSingular($name);
     $doc = JFactory::getDocument();
     if (file_exists(JPATH_BASE . '/media/babioon/images/icon-48-babioon-' . $name . '.png')) {
         $doc->addStyleDeclaration('.icon-48-babioon-' . $name . ' {background-image: url(../media/babioon/images/icon-48-babioon-' . $name . '.png);}');
         $image = 'babioon-' . $name . '.png';
     } else {
         $doc->addStyleDeclaration('.icon-48-babioon {background-image: url(../media/babioon/images/icon-48-babioon.png);}');
         $image = 'babioon.png';
     }
     $user = JFactory::getUser();
     $canDo = BabioonAdHelper::getActions($singular);
     JToolBarHelper::title(JText::_('COM_BABIOONAD_' . $tag), $image);
     // Use sigular
     JToolBarHelper::editList($singular . '.edit');
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::publish($name . '.publish', 'JTOOLBAR_PUBLISH', true);
         JToolBarHelper::unpublish($name . '.unpublish', 'JTOOLBAR_UNPUBLISH', true);
     }
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::checkin($name . '.checkin');
     }
     if ($canDo->get('core.delete')) {
         JToolBarHelper::divider();
         JToolBarHelper::deleteList('', $name . '.delete');
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_babioonad');
     }
 }
Пример #4
0
 /**
  * [__construct description]
  *
  * @param   array  $config  [description]
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->type = JRequest::getVar('type', 1, 'default', 'int');
     $this->typeconf = BabioonAdHelper::getTypeConf($this->type);
     // Get system parameters
     $this->systemconfobj = JComponentHelper::getParams('com_babioonad');
     $this->addTemplatePath(dirname(__FILE__) . '/../legacy');
 }
Пример #5
0
 /**
  * Proxy for getModel.
  *
  * @param   string  $name    Model name
  * @param   string  $prefix  Prefix
  * @param   array   $config  configuration array
  *
  * @return  the model
  */
 public function getModel($name = null, $prefix = 'BabioonAdModel', $config = array('ignore_request' => true))
 {
     if (is_null($name)) {
         $name = BabioonAdHelper::toSingular($this->view_list);
     }
     // Note: Name in singular
     $model = parent::getModel($name, $prefix, $config);
     return $model;
 }
Пример #6
0
 /**
  * Method to display a view.
  *
  * @param   boolean  $cachable   If true, the view output will be cached
  * @param   array    $urlparams  An array of safe url parameters and their variable types,for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Pretty simple
     $app = JFactory::getApplication();
     $view = $app->input->get('view', 'ads');
     BabioonAdHelper::addSubmenu($view);
     $app->input->set('view', $view);
     parent::display();
     return $this;
 }
Пример #7
0
 /**
  * Add the page title and toolbar.
  *
  * @return	void
  */
 protected function addToolbar()
 {
     $doc = JFactory::getDocument();
     $doc->addStyleDeclaration('.icon-48-babioon {background-image: url(../media/babioon/images/icon-48-babioon.png);}');
     $user = JFactory::getUser();
     $canDo = BabioonAdHelper::getActions();
     JToolBarHelper::title(JText::_('COM_BABIOONAD'), 'babioon.png');
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_babioonad');
     }
 }
Пример #8
0
 /**
  * [display description]
  *
  * @param   [type]  $tpl  [description]
  *
  * @return  [type]        [description]
  */
 function display($tpl = null)
 {
     // Check if we get a vaild id
     $id = JRequest::getVar('id', 0);
     $result = BabioonAdHelper::checkIdSimple($id, 0);
     $hash = JRequest::getVar('h', 0);
     $result2 = BabioonAdHelper::checkHash($hash);
     if ($result === false || $result2 === false) {
         $this->displayError();
         return;
     }
     $this->id = $id;
     if (BabioonAdHelper::setEmailCheckOk($id) === false) {
         $this->displayError();
         return;
     }
     $this->setLayout('ok');
     parent::display($tpl);
     return;
 }
Пример #9
0
 /**
  * [saveAd description]
  *
  * @return  [type]  [description]
  */
 function saveAd()
 {
     // Simple check for spam
     $hereweare = JRequest::getVar('hereweare', 'blubb');
     if ($hereweare == $this->getUserState('hereweare')) {
         $hash = BabioonAdHelper::getNextHash();
         $row = JTable::getInstance('ad', 'BabioonAdTable');
         $form = $this->getForm();
         foreach ($form as $elm) {
             $row->{$elm}['name'] = $this->getUserState($elm['name']);
         }
         $row->created = gmdate("Y-m-d H:i:s");
         $row->created_by = 0;
         $row->created_by_alias = 'Website';
         $row->published = 1;
         $row->fk_type = $this->type;
         $row->hash = $hash;
         if (!$row->store()) {
             return JError::raiseWarning(500, $row->getError());
         }
         // Rename uploaded files
         $o_logofile = $this->getUserState('o-logofile');
         if ($o_logofile != '') {
             $dir = dirname($row->logofile);
             $file = strtolower($o_logofile);
             $ppos = strrpos($file, '.');
             $ext = substr($file, $ppos);
             $file = substr($file, 0, $ppos);
             $file = preg_replace('/[^a-z0-9_-]*/', '', $file);
             if ($file == '') {
                 $file = 'logo';
             }
             $file = $row->id . '-' . $file . $ext;
             $newname = $dir . DS . $file;
             if (rename($row->logofile, $newname)) {
                 $row->logofile = $file;
             } else {
                 return JError::raiseWarning(500, 'Can not rename file');
             }
         }
         $o_pdffile = $this->getUserState('o-pdffile');
         if ($o_pdffile != '') {
             $dir = dirname($row->pdffile);
             $file = strtolower($o_pdffile);
             $ppos = strrpos($file, '.');
             $ext = substr($file, $ppos);
             $file = substr($file, 0, $ppos);
             $file = preg_replace('/[^a-z0-9_-]*/', '', $file);
             if ($file == '') {
                 $file = 'pdf';
             }
             $file = $row->id . '-' . $file . $ext;
             $newname = $dir . DS . $file;
             if (rename($row->pdffile, $newname)) {
                 $row->pdffile = $file;
             } else {
                 return JError::raiseWarning(500, 'Can not rename file');
             }
         }
         $con = $this->createContent($row);
         if (JError::isError($con)) {
             return JError::raiseError(500, $con);
         }
         if ($row->chiffre == 0) {
             if ($this->typeconf->get('showaddress', 2) == 5 && $this->systemconfobj->get('getgeo', 1) == 2) {
                 $wegetit = $this->getGeoCoordinateIfNecessary($row);
                 if ($wegetit == 1) {
                     $row->geo_l = $this->getUserState('geo_l');
                     $row->geo_b = $this->getUserState('geo_b');
                 }
             }
         } else {
             $row->geo_l = 0;
             $row->geo_b = 0;
         }
         $row->contentid = $con->id;
         if (!$row->store()) {
             return JError::raiseWarning(500, $row->getError());
         }
         $this->adid = $row->id;
         // All is done clear sessiondata to prevent double saved data
         $this->clearSession();
         return true;
     } else {
         if ($this->getUserState('hereweare') != '') {
             die('---> check failed <---');
         }
         return true;
     }
 }
Пример #10
0
 /**
  * [sendNotifyEmail description]
  *
  * @return [type] [description]
  */
 function sendNotifyEmail()
 {
     $params = JComponentHelper::getParams('com_babioonad');
     $row = JTable::getInstance('contact', 'BabioonAdTable');
     $row->load($this->conid);
     $ad = JTable::getInstance('ad', 'BabioonAdTable');
     $ad->load($row->adid);
     $fromname = $params->get('sendername');
     $from = $params->get('senderemail');
     $email = $ad->email;
     $body = BabioonAdHelper::html2txt($row->text);
     $subject = 'Kontaktaufnahme von: ' . $row->email;
     $mail = JFactory::getMailer();
     if (!$mail->sendMail($from, $fromname, $email, $subject, $body, 1)) {
         return false;
     }
     return true;
 }