コード例 #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 getRssItems($languageCode)
 {
     $sql = "SELECT p.id FROM " . ipTable('page') . " AS p\n            LEFT JOIN " . ipTable('page_storage') . " AS s ON p.id=s.pageId\n            WHERE s.`key`='rssFeed' AND s.`value`=1 AND p.`languageCode`='" . esc($languageCode) . "'\n            ORDER BY p.`createdAt` DESC";
     $rssPageIds = ipDb()->fetchColumn($sql);
     $items = array();
     foreach ($rssPageIds as $pageId) {
         $pageContent = self::getPageContent($pageId);
         if (isset($pageContent['text']) && $pageContent['text']) {
             $item['url'] = ipHomeUrl() . ipPage($pageId)->getUrlPath();
             $item['description'] = $pageContent['text'];
             if (isset($pageContent['heading']) && $pageContent['heading']) {
                 $item['title'] = $pageContent['heading'];
             } else {
                 $item['title'] = ipPage($pageId)->getTitle();
             }
             $items[] = $item;
         }
     }
     return $items;
 }
コード例 #3
0
ファイル: Model.php プロジェクト: quelbs/SitemapXml
 public static function xmlOutput()
 {
     $xml = '<?xml version="1.0" encoding="UTF-8"?>';
     $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     $pages = self::getAllPageIds();
     $urls = array();
     foreach ($pages as $pageId) {
         $page = ipPage($pageId);
         if (!$page || in_array($page->getLink(), $urls)) {
             continue;
         }
         $urls[] = $page->getLink();
         $xml .= '<url>';
         $xml .= '<loc>';
         $xml .= $page->getLink();
         $xml .= '</loc>';
         $xml .= '<lastmod>';
         $xml .= date('Y-m-d', strtotime($page->getUpdatedAt()));
         $xml .= '</lastmod>';
         $xml .= '</url>';
     }
     $xml .= '</urlset>';
     return $xml;
 }
コード例 #4
0
ファイル: AdminController.php プロジェクト: Umz/ImpressPages
 public function getPageTree()
 {
     $language = ipContent()->getCurrentLanguage();
     $sitemap = array(array('text' => $language->getAbbreviation(), 'type' => 'language', 'icon' => 'fa fa-flag-o', 'state' => array('opened' => true), 'children' => array()));
     $menuList = \Ip\Internal\Pages\Model::getMenuList($language->getCode());
     foreach ($menuList as $menu) {
         $page = ipPage($menu['id']);
         $children = array('text' => $menu['title'], 'icon' => 'fa fa-folder-o', 'li_attr' => (object) array('data-url' => $page->getLink()), 'children' => array());
         foreach ($page->getChildren() as $child) {
             $children['children'][] = $this->_addPageToTree($child);
         }
         $sitemap[0]['children'][] = $children;
     }
     $data = array('status' => 'success', 'sitemap' => $sitemap);
     return new \Ip\Response\Json($data);
 }
コード例 #5
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();
 }
コード例 #6
0
ファイル: AdminController.php プロジェクト: Umz/ImpressPages
 public function updatePage()
 {
     ipRequest()->mustBePost();
     $data = ipRequest()->getPost();
     if (empty($data['pageId'])) {
         throw new \Ip\Exception("Missing required parameters");
     }
     $pageId = (int) $data['pageId'];
     $page = ipContent()->getPage($pageId);
     if (!$page) {
         throw new \Ip\Exception("Page doesn't exist");
     }
     $answer = array();
     if (strtotime($data['createdAt']) === false) {
         $answer['errors']['createdAt'] = __('Incorrect date format. Example:', 'Ip-admin', false) . date(" Y-m-d");
     }
     if (strtotime($data['updatedAt']) === false) {
         $answer['errors']['updatedAt'] = __('Incorrect date format. Example:', 'Ip-admin', false) . date(" Y-m-d");
     }
     if ($data['alias'] != $page->getAlias()) {
         if (Model::getPageByAlias($page->getLanguageCode(), $data['alias'])) {
             $answer['errors']['alias'] = __('This alias is already occupied', 'Ip-admin');
         }
     }
     $data['isVisible'] = !empty($data['isVisible']);
     $data['isDisabled'] = !empty($data['isDisabled']);
     $data['isSecured'] = !empty($data['isSecured']);
     $data['isBlank'] = !empty($data['isBlank']);
     if ($page->getUrlPath() == $data['urlPath']) {
         unset($data['urlPath']);
     }
     if (empty($answer['errors'])) {
         Model::updatePageProperties($pageId, $data);
         ipEvent('ipFormUpdatePageSubmitted', array($data));
         $answer['status'] = 'success';
         $answer['newPageUrl'] = ipPage($pageId)->getUrlPath();
     } else {
         $answer['status'] = 'error';
     }
     return new \Ip\Response\Json($answer);
 }
コード例 #7
0
ファイル: Model.php プロジェクト: sspaeti/ImpressPages
 public static function getPages($parentId, $cat, $pag, $options = array())
 {
     $categories = array();
     $ids = array($parentId);
     if ($cat) {
         $result = self::getCategories($parentId);
         if (!empty($result)) {
             $ids = $result['ids'];
             $categories = $result['categories'];
         }
     }
     $idsStr = implode(',', $ids);
     $table = ipTable('page');
     $start = $pag['limit'] * ($pag['page'] - 1);
     $results['pagination'] = $pag;
     $limit = "LIMIT {$start}, {$pag['limit']}";
     switch (!empty($options['order']) ? $options['order'] : 0) {
         case 1:
             $order = "ORDER BY `createdAt` ASC";
             break;
         case 2:
             $order = "ORDER BY `pageOrder` DESC";
             break;
         case 3:
             $order = "ORDER BY `pageOrder` ASC";
             break;
         default:
             $order = "ORDER BY `createdAt` DESC";
             break;
     }
     $where = "WHERE `parentId` IN ({$idsStr}) AND `isVisible` = 1 AND `isDeleted` = 0";
     $sql = "SELECT `id`, `parentId`, `title`, `urlPath`, `createdAt` FROM {$table} {$where} {$order} {$limit}";
     $pages = ipDb()->fetchAll($sql);
     foreach ($pages as &$page) {
         $page['urlPath'] = ipPage($page)->getLink();
         $page = self::getPageIntro($page, $options);
     }
     $results['categories'] = $categories;
     $results['pages'] = $pages;
     $results['pagination']['count'] = self::getPageCount($where);
     return $results;
 }
コード例 #8
0
ファイル: Model.php プロジェクト: Umz/ImpressPages
 /**
  * Change URL path of page
  *
  * @param string $pageId
  * @param string $newUrlPath
  * @return bool|null
  */
 protected static function changePageUrlPath($pageId, $newUrlPath)
 {
     $pageBeforeChange = ipPage($pageId);
     if (ipGetOption('Config.trailingSlash', 1)) {
         if (mb_substr($newUrlPath, -1) != '/') {
             $newUrlPath .= '/';
         }
     } else {
         if (mb_substr($newUrlPath, -1) == '/') {
             $newUrlPath = mb_substr($newUrlPath, 0, -1);
         }
     }
     if ($newUrlPath == $pageBeforeChange->getUrlPath()) {
         return false;
     }
     $allocatedPath = UrlAllocator::allocatePath($pageBeforeChange->getLanguageCode(), $newUrlPath);
     ipDb()->update('page', array('urlPath' => $allocatedPath), array('id' => $pageId));
     $pageAfterChange = ipPage($pageId);
     $oldUrl = $pageBeforeChange->getLink();
     if (substr($oldUrl, -1) == '/') {
         $oldUrl = substr($oldUrl, 0, -1);
     }
     $newUrl = $pageAfterChange->getLink();
     if (substr($newUrl, -1) == '/') {
         $newUrl = substr($newUrl, 0, -1);
     }
     ipEvent('ipUrlChanged', array('oldUrl' => $oldUrl, 'newUrl' => $newUrl));
     return null;
 }
コード例 #9
0
ファイル: Model.php プロジェクト: sspaeti/ImpressPages
 public static function getPageUrl($pageId)
 {
     return ipPage($pageId)->getLink();
 }