public function init() { parent::init(); $this->view->assign('user', $this->view->auth()); $session = new Cible_Sessions(); // Defines the default interface language if ($this->_config->defaultInterfaceLanguage) { $this->_defaultInterfaceLanguage = $this->_config->defaultInterfaceLanguage; } // Check if the current interface language should be different than the default one $this->_currentInterfaceLanguage = !empty($session->languageID) ? $session->languageID : $this->_defaultInterfaceLanguage; if ($this->_getParam('setLang')) { $this->_currentInterfaceLanguage = Cible_FunctionsGeneral::getLanguageID($this->_getParam('setLang')); } // Registers the current interface language for future uses $this->_registry->set('languageID', $this->_currentInterfaceLanguage); $session->languageID = $this->_currentInterfaceLanguage; $suffix = Cible_FunctionsGeneral::getLanguageSuffix($this->_currentInterfaceLanguage); $this->_registry->set('languageSuffix', $suffix); // Defines the default edit language if ($this->_config->defaultEditLanguage) { $this->_currentEditLanguage = $this->_config->defaultEditLanguage; } else { $this->_currentEditLanguage = $this->_defaultEditLanguage; } $this->_currentEditLanguage = !empty($session->currentEditLanguage) ? $session->currentEditLanguage : $this->_currentEditLanguage; // Check if the current edit language should be different than the default one if ($this->_getParam('lang')) { $this->_currentEditLanguage = Cible_FunctionsGeneral::getLanguageID($this->_getParam('lang')); } // Registers the current edit language for future uses $this->_registry->set('currentEditLanguage', $this->_currentEditLanguage); $session->currentEditLanguage = $this->_currentEditLanguage; if (Cible_FunctionsGeneral::extranetLanguageIsAvailable($this->getCurrentInterfaceLanguage()) == 0) { $session = new Cible_Sessions(); $this->_currentInterfaceLanguage = $this->_config->defaultInterfaceLanguage; // Registers the current interface language for future uses $this->_registry->set('languageID', $this->_currentInterfaceLanguage); $session->languageID = $this->_currentInterfaceLanguage; $suffix = Cible_FunctionsGeneral::getLanguageSuffix($this->_currentInterfaceLanguage); $this->_registry->set('languageSuffix', $suffix); } $hasProfile = false; $hasVideos = true; $modProfile = Cible_FunctionsModules::modulesProfile(); if (count($modProfile) > 0) { $hasProfile = true; } $this->view->assign('hasProfile', $hasProfile); $this->view->assign('hasVideos', $hasVideos); }
public function listSubCatAction() { // web page title $this->view->title = "Sous-catégories"; if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) { $tables = array('Catalog_CategoriesData' => array('CC_ID'), 'Catalog_CategoriesIndex' => array('CCI_CategoryID', 'CCI_Name'), 'Catalog_SousCategoriesData' => array('SC_ID', 'SC_CategoryID'), 'Catalog_SousCategoriesIndex' => array('SCI_SousCategoryID', 'SCI_LanguageID', 'SCI_Name')); $field_list = array('SC_ID' => array('width' => '50px'), 'SCI_Name' => array('width' => '150px'), 'CCI_Name' => array('width' => '150px')); $this->view->params = $this->_getAllParams(); $pageID = $this->_getParam('pageID'); $lang = $this->_getParam('lang'); if (!$lang) { $this->_registry->currentEditLanguage = $this->_defaultEditLanguage; $langId = $this->_defaultEditLanguage; } else { $langId = Cible_FunctionsGeneral::getLanguageID($lang); $this->_registry->currentEditLanguage = $langId; } $oSubCategories = new SubCategoriesObject(); $select = $oSubCategories->getAll($langId, false); $select->joinLeft('Catalog_CategoriesData', 'CC_ID = SC_CategoryID'); $select->joinLeft('BannerGroup', 'BG_ID = SC_BannerGroupID'); $select->joinLeft('Catalog_CategoriesIndex', 'CC_ID = CCI_CategoryID AND CCI_LanguageID = "' . $langId . '"'); $commands = array(); if ($langId == $this->_defaultEditLanguage) { $commands = array($this->view->link($this->view->url(array('controller' => $this->_name, 'action' => 'add')), $this->view->getCibleText('button_add_news'), array('class' => 'action_submit add'))); } $options = array('commands' => $commands, 'disable-export-to-excel' => 'true', 'action_panel' => array('width' => '50', 'actions' => array('edit' => array('label' => $this->view->getCibleText('button_edit'), 'url' => $this->view->baseUrl() . "/" . $this->_moduleTitle . "/" . $this->_name . "/edit/" . $this->_paramId . "/%ID%", 'findReplace' => array('search' => '%ID%', 'replace' => 'SC_ID')), 'delete' => array('label' => $this->view->getCibleText('button_delete'), 'url' => $this->view->baseUrl() . "/" . $this->_moduleTitle . "/" . $this->_name . "/delete/" . $this->_paramId . "/%ID%/" . $pageID, 'findReplace' => array('search' => '%ID%', 'replace' => 'SC_ID'))))); $mylist = new Cible_Paginator($select, $tables, $field_list, $options); $this->view->assign('mylist', $mylist); } }
/** * Set options array or the list view. Options are the actions in the page. * * @access public * * @param int $tabId Id of the row to be processed. * @param int $page Id of the page if selected with the paginator. * * @return void */ private function _setActionsList($tabId, $page = 1) { $commands = array(); $actions = array(); $actionPanel = array('width' => '50px'); $options = array(); if (count($this->_actionsList) == 0) { $this->_actionsList = array(array('commands' => ''), array('action_panel' => 'edit')); } foreach ($this->_actionsList as $key => $controls) { foreach ($controls as $key => $action) { //Redirect to the real action to process If no actionKey = list page. switch ($action) { case 'add': $lang = $this->_getParam('lang'); if (!empty($lang)) { $langId = Cible_FunctionsGeneral::getLanguageID($lang); } if ($langId == $this->_defaultEditLanguage) { $commands = array($this->view->link($this->view->url(array('controller' => $this->_name, 'action' => $this->_currentAction, 'actionKey' => 'add')), $this->view->getCibleText('button_add_' . $this->_labelSuffix), array('class' => 'action_submit add'))); } break; case 'edit': $edit = array('label' => $this->view->getCibleText('button_edit'), 'url' => $this->view->baseUrl() . "/" . $this->_moduleTitle . "/" . $this->_name . "/" . $this->_currentAction . "/" . "actionKey/edit/" . $this->_ID . "/%ID%/page/" . $page, 'findReplace' => array(array('search' => '%ID%', 'replace' => $tabId)), 'returnUrl' => $this->view->Url() . "/"); $actions['edit'] = $edit; break; case 'delete': $delete = array('label' => $this->view->getCibleText('button_delete'), 'url' => $this->view->baseUrl() . "/" . $this->_moduleTitle . "/" . $this->_name . "/" . $this->_currentAction . "/" . "actionKey/delete/" . $this->_ID . "/%ID%/page/" . $page, 'findReplace' => array(array('search' => '%ID%', 'replace' => $tabId))); $actions['delete'] = $delete; break; default: break; } } } $actionPanel['actions'] = $actions; $options = array('commands' => $commands, 'action_panel' => $actionPanel); if ($this->_disableExportToExcel) { $options['disable-export-to-excel'] = 'true'; } if ($this->_disableExportToPDF) { $options['disable-export-to-pdf'] = 'true'; } if ($this->_disableExportToCSV) { $options['disable-export-to-csv'] = 'true'; } if ($this->_enablePrint) { $options['enable-print'] = 'true'; } $options['actionKey'] = $this->_currentAction; return $options; }
public function printRegistrationAction() { $id = (int) $this->_getParam('id'); $page = $this->_getParam('page'); $lang = $this->_getParam('lang'); if (!$lang) { $this->_registry->currentEditLanguage = $this->_defaultEditLanguage; $langId = $this->_defaultEditLanguage; } else { $langId = Cible_FunctionsGeneral::getLanguageID($lang); $this->_registry->currentEditLanguage = $langId; } if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) { $firstPData = array(); $secPData = array(); $oMember = new MemberProfilesObject(); $oGeneric = new GenericProfilesObject(); $oMedic = new MedicalProfilesObject(); $oDiseasesD = new DiseasesDetailsObject(); $oParent = new ParentProfilesObject(); $oAddress = new AddressObject(); $sections = $oMember->_sectionSrc(); $memberData = $oMember->populate($id, $langId); $data = $oGeneric->populate($memberData['MP_GenericProfileId'], $langId); $medicData = $oMedic->populate($memberData['MP_GenericProfileId'], $langId); $allergies = $oMedic->_allergySrc(); $diseases = $oMedic->_diseasesSrc(); $diseasesDetails = $oDiseasesD->setFilters(array($oDiseasesD->getForeignKey() => $id)); $diseasesDetails = $oDiseasesD->getAll(); $memberData = array_merge($memberData, $data, $medicData); $this->view->title = 'Membre : ' . $memberData['GP_LastName'] . ' ' . $memberData['GP_FirstName']; $resp = $oParent->_listRespSrc(); $roles = $oParent->_parentsProfileSrc(); if (!empty($data['MP_FirstParent'])) { $firstPData = $oParent->populate($memberData['MP_FirstParent'], $langId); if (empty($firstPData)) { $firstPData = $oParent->populate($memberData['MP_GenericProfileId'], $langId); } $data = $oGeneric->populate($firstPData['PP_GenericProfileId'], $langId); $firstPData = array_merge($firstPData, $data); $address = $oAddress->populate($firstPData['PP_AddressId'], $langId); $firstPData['address'] = $address; } if (!empty($data['MP_SecondParent'])) { $secPData = $oParent->populate($memberData['MP_SecondParent'], $langId); $data = $oGeneric->populate($secPData['PP_GenericProfileId'], $langId); $secPData = array_merge($secPData, $data); $address = $oAddress->populate($secPData['PP_AddressId'], $langId); $secPData['address'] = $address; } $this->view->dataMember = $memberData; $this->view->parents = array($firstPData, $secPData); $this->view->sections = $sections; $this->view->resp = $resp; $this->view->roles = $roles; $this->view->allergies = $allergies; $this->view->diseases = $diseases; $this->view->diseasesDetails = $diseasesDetails; $this->view->typeMedic = $oDiseasesD->_typeMedicSrc(); } }
/** * Creates the list of data for this action for the current object. * * @access public * * @param string $objectName String tot create the good object. * * @return void */ private function _listAction($objectName) { $page = $this->_getParam('page'); $lang = $this->_getParam('lang'); if (!$lang) { $this->_registry->currentEditLanguage = $this->_defaultEditLanguage; $langId = $this->_defaultEditLanguage; } else { $langId = Cible_FunctionsGeneral::getLanguageID($lang); $this->_registry->currentEditLanguage = $langId; } if ($page == '') { $page = 1; } // Create the object from parameter $oData = new $objectName(); if (!empty($this->_orderBy)) { $oData->setOrderBy($this->_orderBy); } // get needed data to create the list $columnData = $oData->getDataColumns(); $dataTable = $oData->getDataTableName(); if (!empty($this->_joinTables)) { foreach ($this->_joinTables as $key => $obj) { $oTmpObj = new $obj(); $tables[$oTmpObj->getDataTableName()] = $oTmpObj->getDataColumns(); $tables[$oTmpObj->getIndexTableName()] = $oTmpObj->getIndexColumns(); } } $indexTable = $oData->getIndexTableName(); $columnIndex = $oData->getIndexColumns(); $tabId = $oData->getDataId(); //Set the tables from previous collected data $tables = array($dataTable => $columnData, $indexTable => $columnIndex); if (!empty($this->_joinTables)) { foreach ($this->_joinTables as $key => $obj) { $oTmpObj = new $obj(); $tables[$oTmpObj->getDataTableName()] = $oTmpObj->getDataColumns(); $tables[$oTmpObj->getIndexTableName()] = $oTmpObj->getIndexColumns(); } } // Set the select query to create the paginator and the list. $select = $oData->getAll($langId, false); $params = array('constraint' => $oData->getForeignKey()); /* If needs to add some data from other table, tests the joinTables * property. If not empty add tables and join clauses. */ $select = $this->_addJoinQuery($select, $params); // Set the the header of the list (columns name used to display the list) $field_list = $this->_colTitle; // Set the options of the list = links for actions (add, edit, delete...) $options = $this->_setActionsList($tabId, $page); //Create the list with the paginator data. $mylist = new Cible_Paginator($select, $tables, $field_list, $options); // Assign the view script for rendering $this->_helper->viewRenderer->setRender($this->_defaultRender); //Assign to the render the list created previously. $this->view->assign('mylist', $mylist); }
public function addAction() { // web page title $videos = new VideoObject(); $listVideo = array(); $listVideo = $videos->getVideosList(); $this->view->title = "Mise en vedette: ajouter"; $lang = $this->_getParam('lang'); if (!$lang) { $this->_registry->currentEditLanguage = $this->_defaultEditLanguage; $langId = $this->_defaultEditLanguage; } else { $langId = Cible_FunctionsGeneral::getLanguageID($lang); $this->_registry->currentEditLanguage = $langId; } // variables $returnAction = $this->_getParam('return'); $baseDir = $this->view->baseUrl(); $cancelUrl = $baseDir . "/" . $this->_moduleTitle . "/" . $this->_name . "/" . $this->_defaultAction . "/"; if ($returnAction) { $returnUrl = $this->_moduleTitle . "/" . $this->_name . "/" . $returnAction; } else { $returnUrl = $this->_moduleTitle . "/" . $this->_name . "/" . $this->_defaultAction; } if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) { $imageSrc = array(); $isNewImage = array(); for ($x = 1; $x <= $this->_imgFeatureNumber; $x++) { $imageSrc[$x] = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg"; $isNewImage[$x] = true; } if ($this->_request->isPost()) { $formData = $this->_request->getPost(); for ($x = 1; $x <= $this->_imgFeatureNumber; $x++) { $IF_Img = 'IF_Img' . $x; if ($formData[$IF_Img] != "") { if ($formData[$IF_Img] != "") { $imageSrc[$x] = $this->_rootImgPath . "tmp/mcith/mcith_" . $formData[$IF_Img]; } } } } // generate the form $form = new FormBannerFeatured(array('moduleName' => $this->_moduleTitle . '/' . $this->_name, 'baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'dataId' => '', 'isNewImage' => $isNewImage, 'imageSrc' => $imageSrc, 'filePath' => $this->_rootFilePath, 'numberImageFeature' => $this->_imgFeatureNumber), $listVideo); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $oData = new BannerFeaturedObject(); $newData = $formData; $recordID = $oData->insert($newData, $this->_defaultEditLanguage); // Save image data for this banner $this->_saveImgData($formData, $recordID, 'add'); /* IMAGES */ mkdir($this->_imagesFolder . $recordID) or die; mkdir($this->_imagesFolder . $recordID . "/tmp") or die("Could not make directory"); $this->_editMode = false; for ($x = 1; $x <= $this->_imgFeatureNumber; $x++) { $IF_Img = 'IF_Img' . $x; if ($newData[$IF_Img] != '') { $this->_setImage($IF_Img, $form, $newData, $recordID); } } $this->_redirect($returnUrl); } else { $form->populate($formData); } } } }
/** * Add action for the current object. * * @access public * * @return void */ public function addAction() { $oDataName = $this->_objectList[$this->_currentAction]; $oData = new $oDataName(); $page = $this->_getParam('page'); $lang = $this->_getParam('lang'); if (!$lang) { $this->_registry->currentEditLanguage = $this->_defaultEditLanguage; $langId = $this->_defaultEditLanguage; } else { $langId = Cible_FunctionsGeneral::getLanguageID($lang); $this->_registry->currentEditLanguage = $langId; } $baseDir = $this->view->baseUrl() . "/"; if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) { $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg"; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if (isset($formData[$this->_imageSrc]) && $formData[$this->_imageSrc] != "") { if ($formData[$this->_imageSrc] != "") { $imageSrc = $this->_rootImgPath . "tmp/mcith/mcith_" . $formData[$this->_imageSrc]; } } } $cancelUrl = $baseDir; $returnModule = $this->_getParam('returnModule'); $returnAction = $this->_getParam('returnAction'); if (!empty($returnModule)) { $cancelUrl .= $returnModule . '/'; } else { $cancelUrl .= $this->_moduleTitle . "/"; } $cancelUrl .= $this->_name . "/"; if (!empty($returnAction)) { $cancelUrl .= $returnAction . '/'; } else { $cancelUrl .= 'general/'; } $cancelUrl .= "page/" . $page; // generate the form $form = new $this->_formName(array('baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'moduleName' => $this->_moduleTitle . "/" . $this->_objectList[$this->_currentAction], 'imageSrc' => $imageSrc, 'imgField' => $this->_imageSrc, 'object' => $oData, 'dataId' => '', 'mode' => 'add', 'isNewImage' => true)); $this->view->form = $form; // action if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($this->_isXmlHttpRequest) { $formData = $this->_mergeFormData($formData); // if (isset ($formData['MP_Status'])) // $oData->save($formData['MP_GenericProfileMemberID'], $formData, $langId); // else $recordID = $oData->insert($formData, $langId); $data = array('success' => true, 'tabTitle' => $this->view->getCibleText('profile_tab_title_' . $this->_currentAction)); echo json_encode($data); } // $formData['LANGUAGE'] = $this->getCurrentEditLanguage(); if ($form->isValid($formData)) { if (!$this->_isXmlHttpRequest) { $formData = $this->_mergeFormData($formData); $recordID = $oData->insert($formData, $langId); $formData['MP_GenericProfileMemberID'] = $recordID; $formData['MP_Status'] = -2; // $this->_oMember->insert($formData, $langId); } /* IMAGES */ if (!empty($this->_imageSrc)) { mkdir($this->_imageFolder . $recordID) or die("Could not make directory"); mkdir($this->_imageFolder . $recordID . "/tmp") or die("Could not make directory"); } if ($form->getValue($this->_imageSrc) != '') { //Get config data $config = Zend_Registry::get('config')->toArray(); //Set sizes for the image $srcOriginal = $this->_imageFolder . "tmp/" . $form->getValue($this->_imageSrc); $originalMaxHeight = $config[$this->_moduleTitle]['image']['original']['maxHeight']; $originalMaxWidth = $config[$this->_moduleTitle]['image']['original']['maxWidth']; $originalName = str_replace($form->getValue($this->_imageSrc), $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc)); $srcMedium = $this->_imageFolder . "tmp/medium_" . $form->getValue($this->_imageSrc); $mediumMaxHeight = $config[$this->_moduleTitle]['image']['medium']['maxHeight']; $mediumMaxWidth = $config[$this->_moduleTitle]['image']['medium']['maxWidth']; $mediumName = str_replace($form->getValue($this->_imageSrc), $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc)); $srcThumb = $this->_imageFolder . "tmp/thumb_" . $form->getValue($this->_imageSrc); $thumbMaxHeight = $config[$this->_moduleTitle]['image']['thumb']['maxHeight']; $thumbMaxWidth = $config[$this->_moduleTitle]['image']['thumb']['maxWidth']; $thumbName = str_replace($form->getValue($this->_imageSrc), $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc)); copy($srcOriginal, $srcMedium); copy($srcOriginal, $srcThumb); Cible_FunctionsImageResampler::resampled(array('src' => $srcOriginal, 'maxWidth' => $originalMaxWidth, 'maxHeight' => $originalMaxHeight)); Cible_FunctionsImageResampler::resampled(array('src' => $srcMedium, 'maxWidth' => $mediumMaxWidth, 'maxHeight' => $mediumMaxHeight)); Cible_FunctionsImageResampler::resampled(array('src' => $srcThumb, 'maxWidth' => $thumbMaxWidth, 'maxHeight' => $thumbMaxHeight)); rename($srcOriginal, $this->_imageFolder . $recordID . "/" . $originalName); rename($srcMedium, $this->_imageFolder . $recordID . "/" . $mediumName); rename($srcThumb, $this->_imageFolder . $recordID . "/" . $thumbName); } // redirect if (!$this->_isXmlHttpRequest) { $this->_redirect($this->_moduleTitle . "/" . $this->_name . "/" . $this->_currentAction . '/actionKey/edit/' . $this->_ID . '/' . $recordID); } } else { if (!$this->_isXmlHttpRequest) { $link = $this->userExistsAction(); $this->view->link = $link; $errors = $form->getMessages(); $key = key($errors['GP_Email']); if ($key != 'regexNotMatch') { $this->view->displayError = true; } } $form->populate($formData); } } } }
public function listAllAction() { if ($this->view->aclIsAllowed('news', 'edit', true)) { $lang = $this->_getParam('lang'); if (!$lang) { $this->_registry->currentEditLanguage = $this->_defaultEditLanguage; $langId = $this->_defaultEditLanguage; } else { $langId = Cible_FunctionsGeneral::getLanguageID($lang); $this->_registry->currentEditLanguage = $langId; } // NEW LIST GENERATOR CODE // $tables = array('NewsData' => array('ND_ID', 'ND_CategoryID', 'ND_Date'), 'NewsIndex' => array('NI_NewsDataID', 'NI_LanguageID', 'NI_Title', 'NI_Status'), 'Status' => array('S_Code'), 'CategoriesIndex' => array('CI_Title')); $field_list = array('NI_Title' => array('width' => '300px'), 'ND_Date' => array(), 'CI_Title' => array(), 'S_Code' => array('width' => '80px', 'postProcess' => array('type' => 'dictionnary', 'prefix' => 'status_'))); $news = new NewsData(); $select = $news->select()->from('NewsData')->setIntegrityCheck(false)->join('NewsIndex', 'NewsData.ND_ID = NewsIndex.NI_NewsDataID')->join('Status', 'NewsIndex.NI_Status = Status.S_ID')->joinRight('CategoriesIndex', 'NewsData.ND_CategoryID = CategoriesIndex.CI_CategoryID')->joinRight('Categories', 'NewsData.ND_CategoryID = Categories.C_ID')->joinRight('Languages', 'Languages.L_ID = NewsIndex.NI_LanguageID')->where('NI_LanguageID = ?', $langId)->where('NewsIndex.NI_LanguageID = CategoriesIndex.CI_LanguageID')->where('C_ModuleID = ?', $this->_moduleID); //->order('NI_Title'); $commands = array(); if ($langId == $this->_defaultEditLanguage) { $commands = array($this->view->link($this->view->url(array('controller' => 'index', 'action' => 'add')), $this->view->getCibleText('button_add_news'), array('class' => 'action_submit add'))); } $options = array('commands' => $commands, 'to-excel-action' => 'all-news-to-excel', 'filters' => array('news-category-filter' => array('default_value' => null, 'associatedTo' => 'ND_CategoryID', 'choices' => Cible_FunctionsCategories::getFilterCategories($this->_moduleID)), 'news-status-filter' => array('label' => 'Filtre 2', 'default_value' => null, 'associatedTo' => 'S_Code', 'choices' => array('' => $this->view->getCibleText('filter_empty_status'), 'online' => $this->view->getCibleText('status_online'), 'offline' => $this->view->getCibleText('status_offline')))), 'action_panel' => array('width' => '50', 'actions' => array('edit' => array('label' => $this->view->getCibleText('button_edit'), 'url' => "{$this->view->baseUrl()}/news/index/edit/newsID/%ID%/lang/%LANG%/return/list-all/", 'findReplace' => array(array('search' => '%ID%', 'replace' => 'ND_ID'), array('search' => '%LANG%', 'replace' => 'L_Suffix'))), 'delete' => array('label' => $this->view->getCibleText('button_delete'), 'url' => "{$this->view->baseUrl()}/news/index/delete/newsID/%ID%/return/list-all/", 'findReplace' => array('search' => '%ID%', 'replace' => 'ND_ID'))))); $mylist = new Cible_Paginator($select, $tables, $field_list, $options); $this->view->assign('mylist', $mylist); } }
/** * Creates the list of data for this action for the current object. * * @access public * * @param string $objectName String tot create the good object. * * @return void */ public function listAction() { $lang = $this->_getParam('lang'); if (!$lang) { $this->_registry->currentEditLanguage = $this->_defaultEditLanguage; $langId = $this->_defaultEditLanguage; } else { $langId = Cible_FunctionsGeneral::getLanguageID($lang); $this->_registry->currentEditLanguage = $langId; } // NEW LIST GENERATOR CODE // $tables = array('Videos' => array('V_ID', 'V_Alias'), 'VideosIndex' => array('VI_ID', 'VI_Description')); $field_list = array('V_Alias' => array('width' => '300px'), 'VI_Description' => array()); $video = new VideoData(); $select = $video->select()->from('Videos')->setIntegrityCheck(false)->join('VideosIndex', 'Videos.V_ID = VideosIndex.VI_ID')->joinRight('Languages', 'Languages.L_ID = VideosIndex.VI_LanguageID')->where('VI_LanguageID = ?', $langId); $options = array('commands' => array($this->view->link($this->view->url(array('controller' => 'index', 'action' => 'add')), $this->view->getCibleText('button_add_video'), array('class' => 'action_submit add'))), 'to-excel-action' => 'all-video-to-excel', 'action_panel' => array('width' => '50', 'actions' => array('edit' => array('label' => $this->view->getCibleText('button_edit'), 'url' => "{$this->view->baseUrl()}/video/index/edit/videoID/%ID%/lang/%LANG%/return/list/", 'findReplace' => array(array('search' => '%ID%', 'replace' => 'V_ID'), array('search' => '%LANG%', 'replace' => 'L_Suffix'))), 'delete' => array('label' => $this->view->getCibleText('button_delete'), 'url' => "{$this->view->baseUrl()}/video/index/delete/videoID/%ID%/return/list/", 'findReplace' => array('search' => '%ID%', 'replace' => 'V_ID'))))); $mylist = new Cible_Paginator($select, $tables, $field_list, $options); $this->view->assign('mylist', $mylist); }
public function listProductsAction() { // web page title $this->view->title = "Produits"; if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) { $tables = array('Catalog_ProductsData' => array('P_ID'), 'Catalog_ProductsIndex' => array('PI_ProductIndexID', 'PI_LanguageID', 'PI_Name')); $field_list = array('P_ID' => array('width' => '50px'), 'PI_Name' => array('width' => '300px')); $this->view->params = $this->_getAllParams(); $pageID = $this->_getParam('pageID'); $lang = $this->_getParam('lang'); if (!$lang) { $this->_registry->currentEditLanguage = $this->_defaultEditLanguage; $langId = $this->_defaultEditLanguage; } else { $langId = Cible_FunctionsGeneral::getLanguageID($lang); $this->_registry->currentEditLanguage = $langId; } $lines = new ProductsObject(); $select = $lines->getAll($langId, false); $select->order('PI_Name ASC'); $commands = array(); if ($langId == $this->_defaultEditLanguage) { $commands = array($this->view->link($this->view->url(array('controller' => $this->_name, 'action' => 'add')), $this->view->getCibleText('button_add'), array('class' => 'action_submit add'))); } $options = array('commands' => $commands, 'disable-export-to-excel' => 'false', 'action_panel' => array('width' => '50', 'actions' => array('edit' => array('label' => $this->view->getCibleText('button_edit'), 'url' => $this->view->baseUrl() . "/" . $this->_moduleTitle . "/" . $this->_name . "/edit/" . $this->_paramId . "/%ID%", 'findReplace' => array('search' => '%ID%', 'replace' => 'P_ID')), 'delete' => array('label' => $this->view->getCibleText('button_delete'), 'url' => $this->view->baseUrl() . "/" . $this->_moduleTitle . "/" . $this->_name . "/delete/" . $this->_paramId . "/%ID%/" . $pageID, 'findReplace' => array('search' => '%ID%', 'replace' => 'P_ID'))))); $mylist = new Cible_Paginator($select, $tables, $field_list, $options); $this->view->assign('mylist', $mylist); } }
public function readAction() { $this->disableLayout(); $this->disableView(); $ressource_dir = dirname(dirname(__FILE__)) . '/ressources'; /* var_dump($this->_request); exit;*/ $feed = $this->_request->getParam('feed'); $catID = $this->_request->getParam('catID'); $feed = str_replace('.xml', "-{$catID}.xml", $feed); $rssLimit = Cible_FunctionsCategories::getRssItemsLimitPerCategory($catID); $langId = Cible_FunctionsGeneral::getLanguageID($this->_request->getParam('lang')); Zend_Registry::set('languageID', $langId); $lang = $this->_request->getParam('lang'); $feed_url = Zend_Registry::get('absolute_web_root') . "/{$this->_request->getParam('lang')}/{$this->_request->getParam('feed')}"; if (file_exists("{$ressource_dir}/{$lang}/{$feed}")) { $lastUpdate = new Zend_Date(filemtime("{$ressource_dir}/{$lang}/{$feed}")); $now = new Zend_Date(); } if (file_exists("{$ressource_dir}/{$lang}/{$feed}") && !$now->isLater($lastUpdate->addMinute($this->_config->rss->refresh->delay))) { $xml = file_get_contents("{$ressource_dir}/{$lang}/{$feed}"); } else { $file = fopen("{$ressource_dir}/{$lang}/{$feed}", "w"); $select = $this->_db->select(); $select->from('NewsData')->joinLeft('NewsIndex', 'NewsData.ND_ID = NewsIndex.NI_NewsDataID')->joinleft('CategoriesIndex', 'CategoriesIndex.CI_CategoryID = NewsData.ND_CategoryID')->joinleft('Categories', 'Categories.C_ID = NewsData.ND_CategoryID')->where('CategoriesIndex.CI_LanguageID = ?', $langId)->where('NewsIndex.NI_LanguageID = ?', $langId)->where('Categories.C_ID = ?', $catID)->where('Categories.C_ShowInRss = ?', 1)->order('ND_Date DESC')->limit($rssLimit); //die($select); $news = $this->_db->fetchAll($select); $feedPubDate = date("r", strtotime('now')); $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; $xml .= "<rss version=\"2.0\">"; $xml .= "<channel>"; $xml .= "<title>" . $this->_config->site->title . "</title>"; $xml .= "<description>"; $xml .= str_replace('##SITE_NAME##', $this->_config->site->title, $this->view->getCibleText('rss_read_description_field_label')); $xml .= "</description>"; $xml .= "<lastBuildDate>{$feedPubDate}</lastBuildDate>"; $xml .= "<link>{$feed_url}</link>"; foreach ($news as $details) { if ($details['NI_Status'] == 1) { // Titres des nouvelles (FR) $title = str_replace("'", "'", $details['NI_Title']); $title = str_replace("<br>", "<br />", $title); $title = str_replace("&", "&", $title); // Textes des nouvelles (FR) $description = str_replace("'", "'", $this->KeepTextOnly($details["NI_Brief"])); $description = htmlspecialchars($description); $description = str_replace("<br>", "<br />", $description); $pubDate = date("r", strtotime($details["ND_ReleaseDate"])); $news_url = Zend_Registry::get('absolute_web_root') . '/' . Cible_FunctionsCategories::getPagePerCategoryView($details["ND_CategoryID"], 'details') . "/ID/{$details['ND_ID']}"; $xml .= "<item>"; $xml .= "<title>{$title}</title>"; $xml .= "<description>{$description}</description>"; $xml .= "<pubDate>{$pubDate}</pubDate>"; $xml .= "<guid>{$news_url}</guid>"; $xml .= "<link>{$news_url}</link>"; $xml .= "</item>"; } } $xml .= "</channel>"; $xml .= "</rss>"; fwrite($file, $xml); fclose($file); } $this->_response->setHeader('Content-Type', 'application/rss+xml'); echo $xml; }