/**
  * Ajax listing of applications
  */
 public function listAction()
 {
     //criteria
     $criteria = array('application_id' => $this->_applicationId);
     if (null != $this->_getParam('langFilter')) {
         $criteria['lang'] = $this->_getParam('langFilter');
     }
     if (null != $this->_getParam('typeFilter')) {
         $criteria['type_id'] = $this->_getParam('typeFilter');
     }
     if (null != $this->_getParam('statusFilter')) {
         $criteria['status'] = $this->_getParam('statusFilter');
     }
     if (null != $this->_getParam('searchFilter')) {
         $criteria['search_filter'] = $this->_getParam('searchFilter');
     }
     //order
     $order = $this->_request->getParam('order');
     if (isset($order)) {
         $order = array($order);
     } else {
         $order = array("p.name ASC");
     }
     $records = Application_Model_ApplicationMapper::getInstance()->fetchAll($criteria);
     /* @var $record Cms_Model_Page */
     foreach ($records as $record) {
         $data['rows'][] = array('id' => $record->get_id(), 'name' => $record->get_name(), 'status' => $this->translate($record->get_status()), 'status_dt' => HCMS_Utils_Time::timeMysql2Local($record->get_status_dt()));
     }
     $this->_helper->json->sendJson($data);
 }
 public function formatUnlimitedDate($date, $str_unlimited = '')
 {
     if (strpos($date, '3000-01-01') !== false) {
         return $str_unlimited;
     } else {
         return HCMS_Utils_Time::timeMysql2Local($date);
     }
 }
Esempio n. 3
0
 public function rss($title = '', $fullUrl = '', $items = array(), $other_data = array())
 {
     $feed = new Zend_Feed_Writer_Feed();
     if ($title != '') {
         $feed->setTitle($title);
         $feed->setDescription($title);
     }
     if ($fullUrl != '') {
         $feed->setLink($fullUrl);
     }
     if (empty($other_data["author"]["name"])) {
         $other_data["author"]["name"] = " ";
     }
     if (empty($other_data["author"]["email"])) {
         $other_data["author"]["email"] = " ";
     }
     if (empty($other_data["author"]["url"])) {
         $other_data["author"]["url"] = " ";
     }
     $feed->addAuthor($other_data["author"]);
     $feed->setDateModified(time());
     /**
      * Add one or more entries. Note that entries must
      * be manually added once created.
      */
     if (is_array($items) && count($items) > 0) {
         foreach ($items as $item) {
             $entry = $feed->createEntry();
             $entry->setTitle($item->get_title());
             $entry->setLink($this->view->serverUrl() . $this->view->url(array('module' => $other_data["url_params"]["module"], 'controller' => $other_data["url_params"]["controller"], 'action' => $other_data["url_params"]["action"], 'url_id' => $item->get_url_id())));
             $publish_date = $item->get_data("publish_date");
             if ($publish_date != '') {
                 $entry->setDateModified(strtotime($item->get_data("publish_date")));
             } else {
                 $entry->setDateModified(strtotime($item->get_posted()));
             }
             $entry->setDateCreated(HCMS_Utils_Time::timeMysql2Ts($item->get_posted()));
             $content = $item->get_content();
             if ($content != '') {
                 $entry->setContent($content);
             }
             $feed->addEntry($entry);
         }
     }
     /**
      * Render the resulting feed to Atom 1.0 and assign to $out.
      * You can substitute "atom" with "rss" to generate an RSS 2.0 feed.
      */
     return $feed->export('rss');
 }
Esempio n. 4
0
 /**
  * List action
  */
 public function contactListAction()
 {
     $page = $this->_request->getParam('page');
     $perPage = $this->_request->getParam('perPage');
     $langFilter = $this->_request->getParam('langFilter');
     $searchFilter = $this->_request->getParam('searchFilter');
     $fromFilter = $this->_request->getParam('fromFilter');
     $toFilter = $this->_request->getParam('toFilter');
     $orderFilter = $this->_request->getParam('order');
     if (isset($fromFilter) && !empty($fromFilter)) {
         $fromFilter = HCMS_Utils_Date::dateLocalToCustom($fromFilter);
     }
     if (isset($toFilter) && !empty($toFilter)) {
         $toFilter = HCMS_Utils_Date::dateLocalToCustom($toFilter);
     }
     if (isset($orderFilter) && !empty($orderFilter)) {
         $orderBy = array($orderFilter);
     } else {
         $orderBy = array('c.posted DESC');
     }
     if (!isset($page) || $page < 1) {
         $page = 1;
     }
     if (!isset($perPage) || $perPage < 1 || $perPage > 100) {
         $perPage = 100;
     }
     $paging = array('page' => $page, 'perPage' => $perPage);
     $criteria = array('application_id' => $this->_applicationId);
     if (isset($searchFilter) && $searchFilter != "") {
         $criteria['search_filter'] = $searchFilter;
     }
     if (isset($langFilter) && $langFilter != "") {
         $criteria['lang_filter'] = $langFilter;
     }
     if (isset($fromFilter) && $fromFilter != "") {
         $criteria['from_filter'] = $fromFilter;
     }
     if (isset($toFilter) && $toFilter != "") {
         $criteria['to_filter'] = $toFilter;
     }
     $records = Contact_Model_ContactMapper::getInstance()->fetchAll($criteria, $orderBy, $paging);
     $data = array('total' => $paging['total'], 'page' => $paging['page'], 'records' => $paging['records'], 'perPage' => $paging['perPage'], 'rows' => array());
     $languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     /* @var $record Application_Model_Candidate */
     foreach ($records as $record) {
         $data['rows'][] = array('id' => $record->get_id(), 'posted' => HCMS_Utils_Time::timeMysql2Local($record->get_posted()), 'first_name' => $record->get_first_name(), 'last_name' => $record->get_last_name(), 'email' => $record->get_email(), 'street' => $record->get_street(), 'country' => $record->get_country(), 'phone' => $record->get_phone(), 'mobile' => $record->get_mobile(), 'fax' => $record->get_fax(), 'zip' => $record->get_zip(), 'city' => $record->get_city(), 'gender' => $this->translate($record->get_gender()), 'description' => $record->get_description(), 'description_short' => $this->view->abbreviate($record->get_description(), 150), 'message' => $record->get_message(), 'message_short' => $this->view->abbreviate($record->get_message(), 150), 'language' => $languages[$record->get_language()]['name']);
     }
     $this->_helper->json->sendJson($data);
 }
 /**
  * List ajax action
  */
 public function listAction()
 {
     $page = $this->_request->getParam('page');
     $perPage = $this->_request->getParam('perPage');
     $orderFilter = $this->_request->getParam('order');
     $criteria = array('application_id' => $this->_applicationId);
     if (null != $this->_getParam('langFilter')) {
         $criteria['lang'] = $this->_getParam('langFilter');
     }
     if (null != $this->_getParam('statusFilter')) {
         $criteria['status'] = $this->_getParam('statusFilter');
     }
     if (null != $this->_getParam('genderFilter')) {
         $criteria['gender'] = $this->_getParam('genderFilter');
     }
     if (null != $this->_getParam('subscribed_from_dt')) {
         $criteria['subscribed_from'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('subscribed_from_dt'));
     }
     if (null != $this->_getParam('subscribed_to_dt')) {
         $criteria['subscribed_to'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('subscribed_to_dt'));
     }
     if (null != $this->_getParam('unsubscribed_from_dt')) {
         $criteria['unsubscribed_from'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('unsubscribed_from_dt'));
     }
     if (null != $this->_getParam('unsubscribed_to_dt')) {
         $criteria['unsubscribed_to'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('unsubscribed_to_dt'));
     }
     if (isset($orderFilter) && !empty($orderFilter)) {
         $orderBy = array($orderFilter);
     } else {
         $orderBy = array('s.subscribed_dt DESC', 's.unsubscribed_dt DESC', 's.id DESC');
     }
     if (!isset($page) || $page < 1) {
         $page = 1;
     }
     if (!isset($perPage) || $perPage < 1 || $perPage > 100) {
         $perPage = 100;
     }
     $paging = array('page' => $page, 'perPage' => $perPage);
     $records = Contact_Model_SubscriptionMapper::getInstance()->fetchAll($criteria, $orderBy, $paging);
     $data = array('total' => $paging['total'], 'page' => $paging['page'], 'records' => $paging['records'], 'perPage' => $paging['perPage'], 'rows' => array());
     $languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     /* @var $record Contact_Model_Subscription */
     foreach ($records as $record) {
         $data['rows'][] = array('id' => $record->get_id(), 'subscribed' => HCMS_Utils_Time::timeMysql2Local($record->get_subscribed_dt()), 'unsubscribed' => HCMS_Utils_Time::timeMysql2Local($record->get_unsubscribed_dt()), 'status' => $record->get_status(), 'first_name' => $record->get_first_name(), 'last_name' => $record->get_last_name(), 'email' => $record->get_email(), 'gender' => $this->translate($record->get_gender()), 'language' => $languages[$record->get_lang()]['name']);
     }
     $this->_helper->json->sendJson($data);
 }
 protected function getRowData($record, $columns)
 {
     $result = array();
     foreach ($columns as $columnId => $column) {
         if ($columnId == 'posted') {
             $result[$columnId] = HCMS_Utils_Time::timeMysql2Local($record->get_posted());
             continue;
         }
         if ($columnId == 'language') {
             $result[$columnId] = $this->_languages[$record->get_language()]['name'];
             continue;
         }
         if ($columnId == 'gender') {
             $result[$columnId] = $this->translate($record->get_gender());
             continue;
         }
         $methodName = 'get_' . $columnId;
         if (!method_exists($record, $methodName)) {
             continue;
         }
         $result[$columnId] = $record->{$methodName}();
         if (isset($column['type']) && in_array($column['type'], array('textarea', 'message'))) {
             $result[$columnId . '_short'] = $this->view->abbreviate($record->{$methodName}(), 150);
         }
     }
     return $result;
 }
Esempio n. 7
0
 /**
  * Format mysql date
  *
  * @param string $date
  * @return string
  */
 public function formatDate($date)
 {
     return HCMS_Utils_Time::timeMysql2Local($date);
 }
Esempio n. 8
0
 protected function savePage($row)
 {
     $titles = explode("\n", $this->data[$row]['Name']);
     if (isset($this->data[$row]['Meta Keywords'])) {
         $metaKeywords = explode("\n", $this->data[$row]['Meta Keywords']);
     }
     if (isset($this->data[$row]['Meta Description'])) {
         $metaDescriptions = explode("\n", $this->data[$row]['Meta Description']);
     }
     $page = new Cms_Model_Page();
     $page->set_application_id(1)->set_format('html')->set_status('published')->set_type_id(1)->set_user_id(1)->set_posted(HCMS_Utils_Time::timeTs2Mysql(time()));
     foreach ($this->languages as $langIndex => $lang) {
         $curRow = $row;
         $title = $this->getLangText($titles, $langIndex);
         if (isset($metaKeywords)) {
             $metaKeyword = $this->getMetaKeywords($metaKeywords, $langIndex);
         }
         if (isset($metaDescriptions)) {
             $metaDescription = $this->getMetaDescription($metaDescriptions, $langIndex);
         }
         $urlIdParts = array();
         while (isset($this->data[$curRow])) {
             $currTitles = explode("\n", $this->data[$curRow]['Name']);
             if (isset($metaKeyword) && isset($metaDescription)) {
                 $meta = array("keywords" => $metaKeyword, "description" => $metaDescription);
             } else {
                 $meta = array("keywords" => "", "description" => "");
             }
             if (isset($currTitles[$langIndex])) {
                 $urlIdParts[] = $this->seoFilter->filter($currTitles[$langIndex]);
             }
             if (!isset($this->data[$curRow]['parent'])) {
                 break;
             }
             $curRow = $this->data[$curRow]['parent'];
         }
         $urlIdParts = array_reverse($urlIdParts);
         $urlId = implode('-', $urlIdParts);
         $page->set_code('')->set_url_id($urlId)->set_content('<h1>' . $title . '</h1>')->set_title($title)->set_meta($meta);
         if (Cms_Model_PageMapper::getInstance()->findByUrlId($urlId, 1, $page)) {
             continue;
         }
         Cms_Model_PageMapper::getInstance()->save($page, $lang);
     }
     $this->data[$row]['page_id'] = $page->get_id();
 }
Esempio n. 9
0
 public function pageEditAction()
 {
     $data = $this->getRequest()->getPost('data');
     $submit = $this->getRequest()->getPost('submit');
     $id = $this->_getParam('id');
     $typeId = $this->_getParam('type_id');
     $langFilter = $this->_getParam('langFilter');
     //check if cancel button is pressed
     if ($this->_formHelper->isCancel()) {
         //cancel form
         return $this->_formHelper->returnCancel($this->view->url(array('action' => 'page')), $this->translate('Action canceled'));
     }
     //create form object
     $form = new Cms_Form_Page($data, null, $langFilter);
     //postback - save?
     if ($this->_formHelper->isSave()) {
         //check if valid
         if ($form->isValid()) {
             $values = $form->getValues();
             //create entity object from submitted values, and save
             $page = new Cms_Model_Page($values);
             //new entity
             if (!isset($data['id']) || $data['id'] <= 0) {
                 $page->set_application_id($this->_applicationId)->set_user_id($this->_admin->get_id())->set_posted(HCMS_Utils_Time::timeTs2Mysql(time()));
             } else {
                 $existingPage = new Cms_Model_Page();
                 if (!Cms_Model_PageMapper::getInstance()->find($data['id'], $existingPage)) {
                     throw new Exception("Page not found");
                 }
                 if ((int) $existingPage->get_application_id() != $this->_applicationId) {
                     throw new Exception("Cannot edit this Page.");
                 }
             }
             Cms_Model_PageMapper::getInstance()->save($page, $langFilter);
             //save categories
             if (isset($data['categories'])) {
                 Cms_Model_PageMapper::getInstance()->saveCategories($page, $data['categories']);
             }
             //save done, return success
             return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'page')), $this->translate('Page saved.'));
         } else {
             //we have errors - return json or continue
             $this->_formHelper->returnError($form->getMessages());
         }
     } elseif (!$this->_formHelper->getRequest()->isPost()) {
         //edit action
         if (isset($id) && $id > 0) {
             $page = new Cms_Model_Page();
             if (!Cms_Model_PageMapper::getInstance()->find($id, $page, $langFilter)) {
                 throw new Exception("Page not found");
             }
             //fetch data
             $data = $page->toArray();
             //populate form with data
             $form->setData($data);
         } else {
             $this->view->typeId = $typeId;
         }
     }
     $this->view->data = $data;
     $this->view->types = Cms_Model_PageTypeMapper::getInstance()->fetchAll();
     //custom elements
     $pageTypes = $this->_application->get_settings("page_types");
     $typeId = $this->_getParam('type_id') ? $this->_getParam('type_id') : $page->get_type_id();
     $this->view->customElements = isset($pageTypes) && isset($pageTypes[$typeId]['custom_elements']) ? $pageTypes[$typeId]['custom_elements'] : array();
 }
Esempio n. 10
0
 public function indexAction()
 {
     $data = $this->getRequest()->getPost('data');
     //print_r($this->_fields);
     //create form object
     $form = new Contact_Form_Generic($data, null, $this->_fields, $this->getRequest());
     $entityClassName = $this->getEntityClassName();
     $mapperClassName = $this->getMapperClassName();
     //postback - save?
     if ($this->_formHelper->isSave()) {
         //check if valid
         if ($form->isValid()) {
             $values = $form->getValues();
             if ($this->hasFileUpload()) {
                 $this->relocateUploadedFiles($values);
                 $this->_genericFileHelper->pmcCleaner();
             }
             //persist data
             if (isset($this->_formParams['db']['save']) && $this->_formParams['db']['save']) {
                 $contact = new $entityClassName($values);
                 $contact->set_application_id($this->_applicationId)->set_language(CURR_LANG)->set_form_id($this->_formId)->set_posted(HCMS_Utils_Time::timeTs2Mysql(time()));
                 $mapperClassName::getInstance()->save($contact);
             }
             //send email
             $this->sendContactEmail($values, $this->_fields, CURR_LANG);
             //sending done, return success
             return $this->redirectLanding();
         } else {
             $this->_formHelper->returnError($form->getMessages());
         }
     } else {
         //set default values
         Contact_Form_Generic::setDefaultValues($this->_fields, $data);
     }
     $this->view->data = $data;
     $this->view->fields = $this->_fields;
     $this->view->formParams = $this->_formParams;
     $this->view->formId = $this->_formId;
     if (isset($this->_formParams['template'])) {
         $this->renderScript($this->_formParams['template']);
     }
 }
Esempio n. 11
0
 public function exportToExcel($applicationId, $headerData, $records, $controller)
 {
     $logger = Zend_Registry::get('Zend_Log');
     try {
         /** PHPExcel */
         //require_once APPLICATION_PATH . '/../library/PHPExcel/PHPExcel.php';
         // Create new PHPExcel object
         $objPHPExcel = new PHPExcel();
         // Set properties
         $objPHPExcel->getProperties()->setCreator("Horisen")->setLastModifiedBy("Horisen")->setTitle("Office  XLS Test Document")->setSubject("Office  XLS Test Document")->setDescription("Test document for Office XLS, generated using PHP classes.")->setKeywords("office 5 openxml php")->setCategory("Test result file");
         // Set active sheet index to the first sheet, so Excel opens this as the first sheet
         $objPHPExcel->setActiveSheetIndex(0);
         //------------- HEADER settings ------------//
         //define style
         $styleHeader = array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('argb' => 'FFA0A0A0')));
         $languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
         //set size of every column
         $columns = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
         foreach ($columns as $value) {
             $objPHPExcel->getActiveSheet()->getColumnDimension($value)->setAutoSize(true);
         }
         $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(20);
         //fill with data
         $activeSheet = $objPHPExcel->getActiveSheet();
         $i = 0;
         foreach ($headerData as $key => $val) {
             $activeSheet->setCellValue($columns[$i] . "1", $controller->translate($val));
             //apply style to header
             $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($i, "1")->applyFromArray($styleHeader);
             $i++;
         }
         //------------- BODY settings ------------//
         //define style
         $styleBody = array('font' => array('bold' => false), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID));
         if (count($records) > 0) {
             //fill with data
             $row = 2;
             foreach ($records as $record) {
                 $col = 0;
                 foreach ($headerData as $key => $value) {
                     if ($key == 'id' || $key == 'application_id') {
                         continue;
                     }
                     if (in_array($key, array('posted', 'subscribed_dt', 'unsubscribed_dt'))) {
                         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, HCMS_Utils_Time::timeMysql2Local($record[$key]));
                     } else {
                         if ($key == 'lang') {
                             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $languages[$record[$key]]['name']);
                         } else {
                             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $record[$key]);
                         }
                     }
                     //set size of every column
                     $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col)->setAutoSize(true);
                     //apply style to body
                     $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->applyFromArray($styleBody);
                     $col++;
                 }
                 $row++;
             }
         }
         return $objPHPExcel;
     } catch (Exception $e) {
         $logger->log($e->getMessage(), Zend_Log::CRIT);
         $logger->log("Exception in export to excel!", Zend_Log::CRIT);
         return false;
     }
 }