コード例 #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
ファイル: Model.php プロジェクト: sspaeti/ImpressPages
 public static function getPageIntro($page, $options)
 {
     $page['intro'] = '';
     $table = ipTable('revision');
     $sql = "SELECT `revisionId` FROM {$table} WHERE `pageId` = {$page['id']} AND isPublished = 1";
     $revisionId = ipDb()->fetchValue($sql);
     $revisionId = !empty($revisionId) ? $revisionId : 0;
     $allowedTags = $options['allowedtags'];
     $blockName = $options['blockname'];
     $introLimit = $options['introlimit'];
     $table = ipTable('widget');
     $sql = "SELECT `position` FROM {$table} WHERE `revisionId` = {$revisionId} AND `isVisible` = 1 AND `isDeleted` = 0 AND `name` = 'AsdBlogSeperator'";
     $position = ipDb()->fetchValue($sql);
     if (!empty($position)) {
         $positionSql = "AND `position` < {$position}";
     } else {
         $positionSql = null;
     }
     $sql = "SELECT `id`, `name`, `skin`, `data`, `blockName` FROM {$table} WHERE `revisionId` = {$revisionId} AND `isVisible` = 1 AND `isDeleted` = 0 AND `blockName` = '{$blockName}' {$positionSql} ORDER BY `position` ASC";
     $widgets = ipDb()->fetchAll($sql);
     $i = 0;
     foreach ($widgets as $widget) {
         if ($widget['name'] == 'Heading' && $i++ == 0) {
             $tmp = json_decode($widget['data'], true);
             $page['title'] = $tmp['title'];
         } elseif ($widget['name'] == 'Text') {
             if (!empty($position)) {
                 $i++;
                 $page['intro'] .= strip_tags(\Ip\Internal\Content\Model::generateWidgetPreview($widget['id'], false), $allowedTags);
             } else {
                 $page['intro'] .= strip_tags(\Ip\Internal\Content\Model::generateWidgetPreview($widget['id'], false), str_replace('</p>', '', $allowedTags));
                 if (mb_strlen($page['intro']) > $introLimit) {
                     $page['intro'] = '<p>' . mb_substr($page['intro'], 0, strpos($page['intro'], ' ', $introLimit)) . '</p>';
                     break;
                 }
             }
         } elseif ($widget['name'] == 'Columns') {
             $columns = self::getWidgetByColumn($widget['id']);
             foreach ($columns as $col) {
                 if ($col['name'] == 'Text') {
                     if (!empty($position)) {
                         $page['intro'] .= strip_tags(\Ip\Internal\Content\Model::generateWidgetPreview($col['id'], false), $allowedTags);
                     } else {
                         $page['intro'] .= strip_tags(\Ip\Internal\Content\Model::generateWidgetPreview($col['id'], false), str_replace('</p>', '', $allowedTags));
                         if (mb_strlen($page['intro']) > $introLimit) {
                             $page['intro'] = '<p>' . mb_substr($page['intro'], 0, strpos($page['intro'], ' ', $introLimit)) . '</p>';
                             break;
                         }
                     }
                 } elseif ($col['name'] == 'Image' && empty($page['image'])) {
                     $page['image'] = json_decode($col['data'], true);
                 }
             }
         } elseif ($widget['name'] == 'Image' && empty($page['image'])) {
             $page['image'] = json_decode($widget['data'], true);
         }
     }
     return $page;
 }
コード例 #3
0
ファイル: PublicController.php プロジェクト: Umz/ImpressPages
 public function index()
 {
     $revision = \Ip\ServiceLocator::content()->getCurrentRevision();
     if ($revision) {
         return \Ip\Internal\Content\Model::generateBlock('main', $revision['revisionId'], 0, ipIsManagementState());
     } else {
         return '';
     }
 }
コード例 #4
0
ファイル: PublicController.php プロジェクト: Umz/ImpressPages
 public function pageNotFound()
 {
     $content = null;
     $error404Page = ipContent()->getPageByAlias('error404');
     if ($error404Page) {
         $revision = \Ip\Internal\Revision::getPublishedRevision($error404Page->getId());
         $content = \Ip\Internal\Content\Model::generateBlock('main', $revision['revisionId'], 0, 0);
     }
     return new \Ip\Response\PageNotFound($content);
 }
コード例 #5
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);
 }
コード例 #6
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);
 }
コード例 #7
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);
 }
コード例 #8
0
ファイル: Block.php プロジェクト: Umz/ImpressPages
 private function generateBlockHtml($revisionId)
 {
     $predefinedContent = \Ip\ServiceLocator::content()->getBlockContent($this->name);
     if ($predefinedContent !== null) {
         return $predefinedContent;
     }
     if (ipContent()->getCurrentPage() == null && $revisionId == 0 && !$this->isStatic) {
         return '';
     }
     if ($this->isStatic) {
         $languageId = ipContent()->getCurrentLanguage()->getId();
         $revisionId = 0;
     } else {
         if ($revisionId === 0) {
             $revision = \Ip\ServiceLocator::content()->getCurrentRevision();
             if ($revision) {
                 $revisionId = $revision['revisionId'];
             }
         }
         $languageId = 0;
     }
     return \Ip\Internal\Content\Model::generateBlock($this->name, $revisionId, $languageId, ipIsManagementState(), $this->exampleContent);
 }
コード例 #9
0
ファイル: Model.php プロジェクト: Umz/ImpressPages
 /**
  * Return float number that will position widget in requested position.
  *
  * @param int $revisionId
  * @param int $languageId
  * @param int $widgetId
  * @param string $newBlockName
  * @param int $newPosition Real position of widget starting with 0
  * @return float
  */
 private static function _calcWidgetPositionNumber($revisionId, $languageId, $widgetId, $newBlockName, $newPosition)
 {
     $allWidgets = Model::getBlockWidgetRecords($newBlockName, $revisionId, $languageId);
     $widgets = array();
     foreach ($allWidgets as $widget) {
         if ($widgetId === null || $widget['id'] != $widgetId) {
             $widgets[] = $widget;
         }
     }
     if (count($widgets) == 0) {
         $positionNumber = 0;
     } else {
         if ($newPosition <= 0) {
             $positionNumber = $widgets[0]['position'] - 40;
         } else {
             if ($newPosition >= count($widgets)) {
                 $positionNumber = $widgets[count($widgets) - 1]['position'] + 40;
             } else {
                 $positionNumber = ($widgets[$newPosition - 1]['position'] + $widgets[$newPosition]['position']) / 2;
             }
         }
     }
     return $positionNumber;
 }
コード例 #10
0
ファイル: Filter.php プロジェクト: impresspages/impresspages
 public static function ipAdminNavbarCenterElements($elements, $info)
 {
     if (ipContent()->getCurrentPage() && ipAdminPermission('Content')) {
         $revision = \Ip\ServiceLocator::content()->getCurrentRevision();
         $revisions = \Ip\Internal\Revision::getPageRevisions(ipContent()->getCurrentPage()->getId());
         $managementUrls = array();
         $currentPageLink = ipContent()->getCurrentPage()->getLink();
         foreach ($revisions as $value) {
             $managementUrls[] = $currentPageLink . '?_revision=' . $value['revisionId'];
         }
         $data = array('revisions' => $revisions, 'currentRevision' => $revision, 'managementUrls' => $managementUrls, 'isPublished' => !\Ip\Internal\Content\Model::isRevisionModified($revision['revisionId']) && ipContent()->getCurrentPage()->isVisible(), 'isVisible' => ipContent()->getCurrentPage()->isvisible());
         $elements[] = ipView('view/publishButton.php', $data);
     }
     return $elements;
 }
コード例 #11
0
ファイル: Controller.php プロジェクト: Umz/ImpressPages
 /**
  * @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();
 }
コード例 #12
0
ファイル: default.php プロジェクト: sspaeti/ImpressPages
    ?>
                    <article <?php 
    if (ipIsManagementState()) {
        echo 'title="' . $tile['label'] . '"';
    }
    ?>
                        class="col-md-4 isotopeItem <?php 
    echo $widgetId . 'all';
    foreach ($tile['filters'] as $f) {
        echo ' ' . $widgetId . $f['filter'];
    }
    ?>
">
				        <div>
                            <?php 
    echo \Ip\Internal\Content\Model::generateBlock('portfolio' . $originalWidgetId . '-' . $tile['blockId'], $revisionId, 0, ipIsManagementState());
    ?>
                        </div>
                    </article>
                <?php 
}
?>
                							  
            </div>
        </div>
    </div>
</div>

<?php 
$portfolioJsScript = '
                
コード例 #13
0
ファイル: Functions.php プロジェクト: Umz/ImpressPages
/**
 * Generate widget HTML
 *
 * @param string $widgetName Widget name.
 * @param array $data Widget's data.
 * @param null $skin Widget skin name.
 * @return string Widget HTML.
 */
function ipRenderWidget($widgetName, $data = array(), $skin = null)
{
    return \Ip\Internal\Content\Model::generateWidgetPreviewFromStaticData($widgetName, $data, $skin);
}