Пример #1
0
 public function save()
 {
     //$form = Helper::createForm($wget='');
     $form = Helper::createForm();
     $postData = ipRequest()->getPost();
     $errors = $form->validate($postData);
     if ($errors) {
         // Validation error
         $status = array('status' => 'error', 'errors' => $errors);
         return new \Ip\Response\Json($status);
     } else {
         // Success
         Model::save(ipRequest()->getPost('language_id'), ipRequest()->getPost('zone_name'), ipRequest()->getPost('user_id'), ipRequest()->getPost('name'), ipRequest()->getPost('email'), ipRequest()->getPost('link'), ipRequest()->getPost('text'), ipRequest()->getPost('ip'), ipRequest()->getPost('approved'), ipRequest()->getPost('session_id'), ipRequest()->getPost('verification_code'), ipRequest()->getPost('active'));
         //get page where this widget sits :)
         $postData = ipRequest()->getPost();
         $vcode = $postData['verification_code'];
         $fullWidgetRecord = \Ip\Internal\Content\Model::getWidgetRecord($postData['wgetId']);
         $pageTitle = '';
         if (isset($fullWidgetRecord['revisionId'])) {
             $revision = \Ip\Internal\Revision::getRevision($fullWidgetRecord['revisionId']);
             if (!empty($revision['pageId'])) {
                 $pageTitle = ipPage($revision['pageId'])->getTitle();
             }
         }
         $stamp = date(__('m/d/Y', 'Comments')) . __(', at ', 'Comments') . date('H:i:s');
         //sending email notification
         Helper::sendMailNotification(trim(ipRequest()->getPost('zone_name')), trim(ipRequest()->getPost('name')), $stamp, trim(ipRequest()->getPost('text')), trim(ipRequest()->getPost('email')), trim($pageTitle), trim($vcode));
         //$actionUrl = ipActionUrl(array('sa' => 'FormExample.showSuccessMessage'));
         //$status = array('redirectUrl' => $actionUrl);
         $status = array('status' => 'ok');
         //success
         return new \Ip\Response\Json($status);
     }
 }
Пример #2
0
 /**
  * WidgetSkeleton.js ask to provide widget management popup HTML. This controller does this.
  * @return \Ip\Response\Json
  * @throws \Ip\Exception\View
  */
 public function widgetPopupHtml()
 {
     $widgetId = ipRequest()->getQuery('widgetId');
     $widgetRecord = \Ip\Internal\Content\Model::getWidgetRecord($widgetId);
     $widgetData = $widgetRecord['data'];
     //create form prepopulated with current widget data
     $form = $this->managementForm($widgetData);
     //Render form and popup HTML
     $viewData = array('form' => $form);
     $popupHtml = ipView('view/editPopup.php', $viewData)->render();
     $data = array('popup' => $popupHtml);
     //Return rendered widget management popup HTML in JSON format
     return new \Ip\Response\Json($data);
 }
Пример #3
0
 /**
  * MasonryGrid.js ask to provide widget management popup HTML. This controller does this.
  * @return \Ip\Response\Json
  * @throws \Ip\Exception\View
  */
 public function widgetPopupHtml()
 {
     $versionParts = explode('.', \Ip\Application::getVersion());
     if (version_compare(\Ip\Application::getVersion(), '4.2.1') < 0) {
         return new \Ip\Response('This widget can be used on ImpressPages 4.2.1 or later.');
     }
     $widgetId = ipRequest()->getQuery('widgetId');
     $widgetRecord = \Ip\Internal\Content\Model::getWidgetRecord($widgetId);
     $widgetData = $widgetRecord['data'];
     $plugin = ipRoute()->plugin();
     //Render form and popup HTML
     $viewData = array('gridUrl' => ipActionUrl(array('aa' => $plugin . '.grid', 'disableAdminNavbar' => 1, 'widgetId' => $widgetId)));
     $popupHtml = ipView('view/editPopup.php', $viewData)->render();
     $data = array('popup' => $popupHtml);
     //Return rendered widget management popup HTML in JSON format
     return new \Ip\Response\Json($data);
 }
Пример #4
0
 /**
  * GridWidget.js ask to provide widget management popup HTML. This controller does this.
  * @return \Ip\Response\Json
  * @throws \Ip\Exception\View
  */
 public function widgetPopupHtml()
 {
     $versionParts = explode('.', \Ip\Application::getVersion());
     if (empty($versionParts[2]) || $versionParts[0] < 4 || $versionParts[0] == 4 && $versionParts[1] < 2 || $versionParts[0] == 4 && ($versionParts[1] = 2 && $versionParts[2] < 1)) {
         return new \Ip\Response('This widget can be used on ImpressPages 4.2.1 or later.');
     }
     $widgetId = ipRequest()->getQuery('widgetId');
     $widgetRecord = \Ip\Internal\Content\Model::getWidgetRecord($widgetId);
     $widgetData = $widgetRecord['data'];
     //create form prepopulated with current widget data
     $form = $this->managementForm($widgetData);
     $plugin = ipRoute()->plugin();
     //Render form and popup HTML
     $viewData = array('gridUrl' => ipActionUrl(array('aa' => $plugin . '.grid', 'disableAdminNavbar' => 1, 'widgetId' => $widgetId)));
     $popupHtml = ipView('view/editPopup.php', $viewData)->render();
     $data = array('popup' => $popupHtml);
     //Return rendered widget management popup HTML in JSON format
     return new \Ip\Response\Json($data);
 }
Пример #5
0
 /**
  * @param \Ip\Form $form
  * @param array $postData
  * @param array $data
  */
 public function sendEmail($form, $postData, $data)
 {
     $contentData = array();
     $websiteName = ipGetOptionLang('Config.websiteTitle');
     $websiteEmail = ipGetOptionLang('Config.websiteEmail');
     $from = $websiteEmail;
     $files = array();
     foreach ($form->getFields() as $field) {
         if ($field->getType() == \Ip\Form\Field::TYPE_REGULAR) {
             if (!isset($postData[$field->getName()])) {
                 $postData[$field->getName()] = null;
             }
             $title = $field->getLabel();
             $value = $field->getValueAsString($postData, $field->getName());
             $contentData[] = array('fieldClass' => get_class($field), 'title' => $title, 'value' => $value);
         }
         if (get_class($field) == 'Ip\\Form\\Field\\Email') {
             $userFrom = $field->getValueAsString($postData, $field->getName());
             if ($userFrom != '') {
                 $from = $userFrom;
             }
         }
         if (get_class($field) == 'Ip\\Form\\Field\\File') {
             $uploadedFiles = $field->getFiles($postData, $field->getName());
             $originalNames = $field->originalFileNames($postData, $field->getName());
             foreach ($uploadedFiles as $key => $uploadedFile) {
                 $files[] = array($uploadedFile, $originalNames[$key]);
             }
         }
     }
     $content = ipView('helperView/email_content.php', array('values' => $contentData))->render();
     $emailData = array('content' => $content);
     $email = ipEmailTemplate($emailData);
     //get page where this widget sits :)
     $fullWidgetRecord = \Ip\Internal\Content\Model::getWidgetRecord($postData['widgetId']);
     $pageTitle = '';
     if (isset($fullWidgetRecord['revisionId'])) {
         $revision = \Ip\Internal\Revision::getRevision($fullWidgetRecord['revisionId']);
         if (!empty($revision['pageId'])) {
             $pageTitle = ipPage($revision['pageId'])->getTitle();
         }
     }
     $subject = $websiteName . ': ' . $pageTitle;
     $emailQueue = new \Ip\Internal\Email\Module();
     if (!empty($data['sendTo']) && $data['sendTo'] == 'custom') {
         if (empty($data['emails'])) {
             $data['emails'] = '';
         }
         $emailList = preg_split("/[\\s,]+/", $data['emails']);
     } else {
         $emailList = array($websiteEmail);
     }
     foreach ($emailList as $listItem) {
         $emailQueue->addEmail($from, '', $listItem, '', $subject, $email, false, true, $files);
     }
     $emailQueue->send();
 }