示例#1
0
 public function init()
 {
     $front = Zend_Controller_Front::getInstance();
     $request = $front->getRequest();
     $action_name = $request->getActionName();
     $this->medias_model = new Default_Model_Medias();
     $this->translate_messages_model = new Locale_Model_TranslateMessages();
     $shared_media_id = $this->_getParam('img');
     $this->view->autoshow_image = (bool) $shared_media_id;
     switch ($action_name) {
         case 'gallery':
             $page = 'foto-galerija';
             break;
         case 'menu':
             $page = 'jelovnik';
             break;
         case 'rooms':
             $page = 'sobe';
             break;
         default:
             $page = 'index';
     }
     $shared_media = $this->medias_model->getById($shared_media_id);
     if ($shared_media) {
         $this->view->fb_title = $shared_media->title;
         $this->view->fb_description = $shared_media->description;
         $this->view->fb_image = Zend_Registry::get('server_url') . My_Utilities::getFullMediaPathDiffSizes($shared_media, 'original');
         $this->view->fb_url = Zend_Registry::get('server_url') . "/" . $page . "/" . $shared_media_id;
     } else {
         $this->view->fb_title = $this->translate_messages_model->getTranslateForLocale('meta_fb_title');
         $this->view->fb_description = $this->translate_messages_model->getTranslateForLocale('meta_fb_description');
         $this->view->fb_image = Zend_Registry::get('server_url') . '/images/' . strtolower(Zend_Registry::get('Zend_Locale')) . '/1170/index-zupska-avlija-logo.png';
         $this->view->fb_url = Zend_Registry::get('server_url');
     }
 }
示例#2
0
文件: Medias.php 项目: zelimirus/yard
 public function init()
 {
     $media_library_model = new Cms_Model_MediaLibraries();
     $media_library = $media_library_model->getByPath($this->_attribs['media_library_path']);
     $title = new Zend_Form_Element_Text('title');
     $title->setLabel('Title');
     $title->setRequired(true);
     $title->addFilter('StringTrim');
     $title->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     $this->addElement($title);
     $description = new Zend_Form_Element_Textarea('description');
     $description->setLabel('Description');
     $description->addFilter('StringTrim');
     $description->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     $this->addElement($description);
     $original = new Zend_Form_Element_File('original');
     $original->addValidator('Count', false, 1);
     $original->addValidator('Extension', false, 'jpeg,jpg,png');
     $original->addFilter('Rename', $this->_attribs['file_name']);
     $original->setDestination(My_Utilities::getUploadMediaPathDiffSizes($this->_attribs['file_name'], $this->_attribs['media_library_path'], 'original'));
     $original->setLabel('Image:');
     $this->addElement($original);
     $submit = new Zend_Form_Element_Submit('save');
     $submit->setAttrib('class', 'btn btn-primary');
     $submit->setLabel('Potvrdi');
     $this->setAction('')->setMethod('post')->addElement($submit);
     $cancel = new Zend_Form_Element_Button('cancel');
     $cancel->setLabel('Cancel');
     $cancel->setAttrib('class', 'btn btn-gold')->setAttrib('style', 'color:black');
     $cancel->setAttrib("onClick", "window.location = window.location.origin+'/cms/medias/index/library_id/" . $media_library->id . "'");
     $this->addElement($cancel);
 }
示例#3
0
 public function deleteAction()
 {
     if ($this->admin_menu_items_model->doDelete((int) $this->_getParam('id', 0))) {
         My_Utilities::fmsg('Record is succesfully deleted.', 'success');
     } else {
         My_Utilities::fmsg('Record is not deleted.', 'error');
     }
     $this->_redirect('admin/menu-items/index/page/' . $this->_getParam('page', 1));
 }
 public function deleteAction()
 {
     $model_translate_keys = new Locale_Model_TranslateKeys();
     if ($model_translate_keys->doDelete((int) $this->_getParam('id', 0))) {
         My_Utilities::fmsg('Data successfully deleted.', 'success');
     } else {
         My_Utilities::fmsg('Error. Record not deleted.', 'error');
     }
     $this->_redirect('/locale/translate-keys/index/' . $this->_getParam('page', 1));
 }
 public function privilegesAction()
 {
     // Try to find record by user id
     $this->view->existing = $this->roles_model->getById((int) $this->_request->getParam('id', 0));
     // If row does not exist, redirect to usersgroups
     if (!isset($this->view->existing->id) || empty($this->view->existing->id)) {
         My_Utilities::fmsg('Record not found.', 'warning');
         $this->_redirect('admin/admin-usersgroups');
     }
     $this->view->form = new Admin_Form_Privileges(array('roleid' => $this->view->existing->id));
     // Check is post and is posted data valid
     if ($this->_request->isPost() && $this->view->form->isValid($_POST)) {
         // First delete than insert
         $this->permissions_model->doDeleteSpecialPermisionsByRole($this->view->existing->id);
         foreach ($this->view->form->getValues() as $key => $rec) {
             if (strstr($key, '_')) {
                 $exp = explode('_', $key);
                 foreach (explode(';', $rec) as $action) {
                     if (!$action) {
                         continue;
                     }
                     $data = array('role_id' => $this->view->existing->id, 'resource_id' => $exp[0], 'action' => trim($action), 'is_allowed' => $exp[1] == 'allow' ? 't' : 'f');
                     $this->permissions_model->doSave($data);
                 }
             }
         }
         My_Utilities::fmsg('Changes are saved.');
         $this->_redirect('admin/admin-usersgroups/index/page/' . $this->_getParam('page', 1));
     }
 }
示例#6
0
 public function deactivateAction()
 {
     $this->view->existing = $this->admin_users_model->getById((int) $this->_getParam('id', 0));
     if ($this->admin_users_model->doSave(array('is_active' => false), (int) $this->_getParam('id', 0))) {
         My_Utilities::fmsg('Record is deactivated.');
     } else {
         My_Utilities::fmsg('Record is not succesfully deactivated.', 'error');
     }
     $this->_redirect('admin/admin-users/index/page/' . $this->_getParam('page', 1));
 }
示例#7
0
 private function deleteMedia($media_id)
 {
     $media = $this->medias_model->getById($media_id);
     $array = array('original');
     array_pop($array);
     if ($this->medias_model->doDelete($media['id'])) {
         foreach ($array as $one) {
             $image_path = substr(My_Utilities::getUploadMediaPathDiffSizes($media['file_name'], $media['path'], $one) . '/' . $media['file_name'], 0, -4);
             foreach (glob($image_path . '.*') as $file_name) {
                 if (is_file($file_name)) {
                     unlink($file_name);
                 }
             }
         }
         return true;
     } else {
         return false;
     }
 }
示例#8
0
 public function deactivateAction()
 {
     $countries = new Locale_Model_Countries();
     if ($countries->doSave(array('is_active' => false), (int) $this->_getParam('id', 0))) {
         My_Utilities::fmsg('Record deactivated');
     } else {
         My_Utilities::fmsg('Error. Record not deactivated', 'error');
     }
     $this->_redirect('locale/countries/index/page/' . $this->_getParam('page', 1));
 }
 public function deleteAction()
 {
     $id = (int) $this->_getParam('id', 0);
     $media_ids = $this->medias_model->getIdsArrayByMediaLibId($id);
     $media_lib = $this->media_libraries_model->getById($id);
     $dir = Zend_Registry::get('upload_media_path') . '/' . $media_lib['path'];
     if (!My_Utilities::deleteDirectory($dir)) {
         My_Utilities::fmsg('Greška. Nije izbrisan folder.', 'error');
         $this->_redirect('/cms/media-libraries/index/page/' . $this->_getParam('page', 1));
     }
     if ($this->media_libraries_model->doDelete($id)) {
         $this->media_libraries_medias_model->doDeleteByMediaLibraryId($id);
         $this->medias_model->doDeleteByIdsArray($media_ids);
         My_Utilities::fmsg('Zapis je uspešno obrisan.', 'success');
     } else {
         My_Utilities::fmsg('Zapis nije obrisan.', 'error');
     }
     $this->_redirect('/cms/media-libraries/index/page/' . $this->_getParam('page', 1));
 }
 /**
  * Upload CSV file. Delete all records from DB table and insert them again
  */
 public function uploadAction()
 {
     $this->view->form = new Locale_Form_UploadTranslate();
     //We don't want to save file but only read content
     if ($this->_request->isPost() && $this->view->form->isValid($_POST)) {
         $data = My_Utilities::readCsv($_FILES['file']['tmp_name']);
         if ($data === false || !count($data)) {
             My_Utilities::fmsg("Error, data not uploaded.", 'error');
             return;
         }
         $result = $this->_model_t_messages->doSaveUpload($data);
         if ($result['success']) {
             My_Utilities::fmsg("Translation succsessfully uploaded.");
             $this->deleteCache();
             $this->_redirect('/locale/translate-messages/index/' . $this->_getParam('page', 1));
         } else {
             My_Utilities::fmsg("Writting into DB not accomplished." . $result['error'], 'error');
         }
     }
 }
示例#11
0
 public function deactivateAction()
 {
     if ($this->languages_model->doSave(array('is_active' => false), (int) $this->_getParam('id', 0))) {
         My_Utilities::fmsg('Record deactivated');
     } else {
         My_Utilities::fmsg('Error. Record not deactivated', 'error');
     }
     $this->_redirect('locale/languages/index/page/' . $this->_getParam('page', 1));
 }