Ejemplo n.º 1
0
 function config_edit($config_id = null)
 {
     if ($config_id) {
         $data = $this->File_uploads_config_model->get_config_by_id($config_id);
     } else {
         $data = array();
     }
     if ($this->input->post('btn_save')) {
         $post_data = array("name" => $this->input->post('name', true), "gid" => $this->input->post('gid', true), "max_size" => $this->input->post('max_size', true), "name_format" => $this->input->post('name_format', true), "file_formats" => $this->input->post('file_formats', true));
         $validate_data = $this->File_uploads_config_model->validate_config($config_id, $post_data);
         if (!empty($validate_data["errors"])) {
             $this->system_messages->add_message('error', $validate_data["errors"]);
             $data = array_merge($data, $validate_data["data"]);
         } else {
             $data = $validate_data["data"];
             $this->File_uploads_config_model->save_config($config_id, $data);
             $this->system_messages->add_message('success', $config_id ? l('success_updated_config', 'file_uploads') : l('success_added_config', 'file_uploads'));
             $url = site_url('admin/file_uploads/configs');
             redirect($url);
         }
     }
     $this->template_lite->assign('data', $this->File_uploads_config_model->format_config($data));
     $this->template_lite->assign('formats', $this->File_uploads_config_model->file_categories);
     $this->template_lite->assign('lang_name_format', ld('upload_name_format', 'file_uploads'));
     $this->system_messages->set_data('header', l('admin_header_configs_list', 'file_uploads'));
     $this->template_lite->view('edit_settings');
 }
 public function indexAction()
 {
     //$em = $this->getDoctrine()->getManager();
     //$user = $em->getRepository('AcmeBlogBundle:User')->find(1);
     ld($this->get('security.context')->getToken());
     return $this->render('AcmeBlogBundle:Admin:index.html.twig');
 }
Ejemplo n.º 3
0
 /**
  * transformToFile
  *
  * @param SplFileInfo $file
  * @access private
  * @return Photo
  */
 public function transformToFile(SplFileInfo $file)
 {
     $photo = $this->transform(new Photo(), $file);
     try {
         $imagick = new Imagick($file->getRealPath());
         if (in_array($imagick->getImageMimeType(), $this->allowedMimeTypes)) {
             $photo->setDisplayable(true);
         }
         // treat width & height
         $geometry = $imagick->getImageGeometry();
         if (in_array($imagick->getImageOrientation(), [Imagick::ORIENTATION_RIGHTTOP, Imagick::ORIENTATION_LEFTBOTTOM])) {
             $photo->setWidth($geometry['height'])->setHeight($geometry['width']);
         } else {
             $photo->setWidth($geometry['width'])->setHeight($geometry['height']);
         }
         // treat Exif datas
         $tmpExif = $imagick->getImageProperties('exif:*');
         $exif = [];
         foreach ($tmpExif as $key => $value) {
             $exif[str_replace('exif:', '', $key)] = $value;
         }
         if (!empty($exif)) {
             $photo->setExif($exif);
         }
     } catch (ImagickException $e) {
         ld($e, $file);
     }
     return $photo;
 }
Ejemplo n.º 4
0
 public function format_field($data, $lang_id = '')
 {
     $data = parent::format_field($data, $lang_id);
     $data["option_module"] = $data["section_gid"] . '_lang';
     $data["option_gid"] = 'field_' . $data["gid"] . '_opt';
     $data["options"] = ld($data["option_gid"], $data["option_module"], $lang_id);
     return $data;
 }
 public function onKernelResponse(FilterResponseEvent $event)
 {
     echo '<h2>Evento: kernel.response</h2>';
     ld($event);
     //$date = new \DateTime();
     //$date->modify('+60 seconds');
     //$event->getResponse()->setExpires($date);
 }
Ejemplo n.º 6
0
/**
 * Template_Lite {ld} function plugin
 *
 * Type:     function
 * Name:     ld
 * Purpose:  Gets names of variables in data sources for multilang purposes
 * Input:
 *           - gid
 *           - i = the shortname of the variable 
 *           
 * Author:   Ruslan Abramov
 */
function tpl_function_ld($params, &$tpl)
{
    $assign = !empty($params['assign']) ? $params['assign'] : 'ld_' . $params['i'];
    $assign = str_replace(array(' ', '-'), '_', $assign);
    $assign = preg_replace('/[^a-z0-9_]/i', '', $assign);
    $ld = ld($params['i'], $params['gid']);
    $tpl->assign($assign, $ld);
    return '';
}
Ejemplo n.º 7
0
/**
 * Generate date string from format
 * @param str $format (ex. dd/mm/yy)
 * @param int $timestamp (from mktime)
 */
function generate_date_str($format, $timestamp, $use_time = false)
{
    // load lang settings for date
    $CI =& get_instance();
    $CI->load->model('lang_config');
    $lang_config = $CI->lang_config->get_config();
    $separator = isset($lang_config['date_separator_str']) ? $lang_config['date_separator_str'] : ' ';
    $result = '';
    $i = 0;
    foreach ($format as $f) {
        $i++;
        switch ($f) {
            case 'dd':
                $result .= adodb_date('d', $timestamp);
                break;
            case 'd':
                $result .= adodb_date('j', $timestamp);
                break;
            case 'mm':
                $result .= adodb_date('m', $timestamp);
                break;
            case 'MM':
                $result .= ld('months', adodb_date('n', $timestamp));
                break;
            case 'yy':
                $result .= adodb_date('Y', $timestamp);
                break;
            default:
                break;
        }
        // add separator
        if ($i != count($format)) {
            $result .= $separator;
        }
    }
    if ($use_time) {
        $result .= ' ';
        if (1 == $lang_config['show_24_hour']) {
            $result .= adodb_date('H', $timestamp);
        } else {
            $result .= adodb_date('h', $timestamp);
        }
        $result .= $lang_config['time_separator_str'];
        $result .= adodb_date('i', $timestamp);
        if (1 == $lang_config['show_seconds']) {
            $result .= $lang_config['time_separator_str'];
            $result .= adodb_date('s', $timestamp);
        }
        if (1 != $lang_config['show_24_hour']) {
            $result .= isset($lang_config['ampm_prefix_str']) ? $lang_config['ampm_prefix_str'] : ' ';
            $result .= adodb_date('A', $timestamp);
        }
    }
    return $result;
}
Ejemplo n.º 8
0
 public function rezerwujAction($date, $param, Request $request)
 {
     $date = substr($date, 4, 11);
     $zamknij = false;
     $form = $this->createFormBuilder()->add('godzina_rozpoczecia', 'choice', array('choices' => array($date . ' 09:00:00' => '9', $date . ' 10:00:00' => '10', $date . ' 11:00:00' => '11', $date . ' 12:00:00' => '12', $date . ' 13:00:00' => '13', $date . ' 14:00:00' => '14', $date . ' 15:00:00' => '15', $date . ' 16:00:00' => '16', $date . ' 17:00:00' => '17', $date . ' 18:00:00' => '18', $date . ' 19:00:00' => '19', $date . ' 20:00:00' => '20'), 'required' => true))->add('godzina_zakonczenia', 'choice', array('choices' => array($date . ' 10:00:00' => '10', $date . ' 11:00:00' => '11', $date . ' 12:00:00' => '12', $date . ' 13:00:00' => '13', $date . ' 14:00:00' => '14', $date . ' 15:00:00' => '15', $date . ' 16:00:00' => '16', $date . ' 17:00:00' => '17', $date . ' 18:00:00' => '18', $date . ' 19:00:00' => '19', $date . ' 20:00:00' => '20', $date . ' 21:00:00' => '21'), 'required' => true))->add('save', 'submit')->getForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         $data_zakonczenia = date_create_from_format('M d Y H:i:s', $data['godzina_zakonczenia']);
         $data_zakonczenia_sek = $data_zakonczenia->getTimestamp();
         $data_rozpoczecia = date_create_from_format('M d Y H:i:s', $data['godzina_rozpoczecia']);
         $data_rozpoczecia_sek = $data_rozpoczecia->getTimestamp();
         if ($data_zakonczenia_sek < $data_rozpoczecia_sek + 3600) {
             echo 'godzina zakonczenia musi byc wieksza przynajmniej o 1';
         } else {
             if ($param == 'calendar') {
                 $em = $this->getDoctrine()->getManager();
                 $torEvents = $em->getRepository('TorBundle:ReservationTor')->createQueryBuilder('tor_events')->where('(tor_events.dataStart <= :startDate and tor_events.dateStop > :startDate) or (tor_events.dataStart < :endDate and tor_events.dateStop >= :endDate) or (tor_events.dataStart > :startDate and tor_events.dateStop < :endDate)')->setParameter('startDate', $data_rozpoczecia)->setParameter('endDate', $data_zakonczenia)->getQuery()->getResult();
                 if (empty($torEvents)) {
                     echo 'nic nie ma';
                     $reservation = new ReservationTor();
                     $reservation->setDataStart($data_rozpoczecia);
                     $reservation->setDateStop($data_zakonczenia);
                     $user = $this->getUser();
                     $reservation->setUserId($user);
                     $em->persist($reservation);
                     $em->flush();
                     $zamknij = true;
                 } else {
                     echo 'Podany czas jest już zarezerwowany';
                 }
             } else {
                 $em = $this->getDoctrine()->getManager();
                 $torEvents = $em->getRepository('TorBundle:InstructorsReservation')->createQueryBuilder('tor_events')->where('(tor_events.idInstructor = :param) and ((tor_events.dateStart <= :startDate and tor_events.dateStop > :startDate) or (tor_events.dateStart < :endDate and tor_events.dateStop >= :endDate) or (tor_events.dateStart > :startDate and tor_events.dateStop < :endDate))')->setParameter('startDate', $data_rozpoczecia)->setParameter('endDate', $data_zakonczenia)->setParameter('param', $param)->getQuery()->getResult();
                 if (empty($torEvents)) {
                     echo 'nic nie ma';
                     $reservation = new InstructorsReservation();
                     $reservation->setDateStart($data_rozpoczecia);
                     $reservation->setDateStop($data_zakonczenia);
                     $user = $this->getUser();
                     $reservation->setIdUser($user);
                     $instructor = $em->getRepository('TorBundle:Instructors')->find($param);
                     $reservation->setIdInstructor($instructor);
                     $em->persist($reservation);
                     $em->flush();
                     $zamknij = true;
                 } else {
                     ld($torEvents);
                 }
             }
         }
     }
     return $this->render('TorBundle:tor:rezerwuj.html.twig', array('form' => $form->createView(), 'zamknij' => $zamknij));
 }
Ejemplo n.º 9
0
 public static function Run()
 {
     require_once __DIR__ . '/../autoload.php';
     try {
         $router = new Router();
         $router->Start();
     } catch (\Exception $e) {
         //TODO: критическое логирование
         ld($e);
         die('Критическое исключение');
     }
 }
Ejemplo n.º 10
0
 /**
  * @Route("/admin/schedule/test")
  * @Template("TSKScheduleBundle:Default:repeat.html.twig")
  */
 public function testAction()
 {
     $em = $this->getDoctrine()->getManager();
     $scheduleEntity = $em->getRepository('TSK\\ScheduleBundle\\Entity\\ScheduleEntity')->find(8);
     // $processor = $this->get('tsk_schedule.processor.schedule_instances');
     // $processor->processEntity($scheduleEntity);
     $scheduleEntity->setTitle('yoga ' . time());
     $em->persist($scheduleEntity);
     $em->flush();
     ld($scheduleEntity);
     exit;
     return array('form' => 'foo');
 }
Ejemplo n.º 11
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $dialog = $this->getDialogHelper();
         $context = $input->getOption('context');
         $manager = $this->getContainer()->get('doctrine.orm.entity_manager');
         if ($context) {
             $method = 'findBy';
             $ruleContextRepo = $manager->getRepository('TSKRulerBundle:RuleContext');
             $ruleContext = $ruleContextRepo->findOneBy(array('name' => $context));
             if (!$ruleContext) {
                 throw new \Exception('No rule context [' . $context . ']');
             }
             $clauses['context'] = $ruleContext;
             $this->context = $ruleContext->getName();
         } else {
             $method = 'findAll';
             $clauses = array();
         }
         $this->rules = array();
         $rcRepo = $manager->getRepository('TSKRulerBundle:RuleCollection');
         $ruleCollections = $rcRepo->{$method}($clauses);
         if ($ruleCollections) {
             foreach ($ruleCollections as $rc) {
                 $idx = 0;
                 foreach ($rc->getRuleGroups() as $ruleGroup) {
                     $this->processRuleGroup($ruleGroup, $idx++, $rc->getContext()->getName(), $rc->getDescription());
                 }
             }
             ld($this->rules);
             $dumper = new Dumper();
             $yaml = $dumper->dump($this->rules, 2);
             file_put_contents('/Users/mhill/projects/tsk-erp-system/src/TSK/RulerBundle/Resources/files/rules.yml', $yaml);
             print $yaml;
         } else {
             print 'no rule collections';
         }
     } catch (\Exception $e) {
         $dialog = $this->getDialogHelper();
         $dialog->writeSection($output, $e->getMessage(), 'bg=red;fg=white');
     }
     if (!empty($results['errors'])) {
         $dialog = $this->getDialogHelper();
         $dialog->writeSection($output, $results['errors'][0], 'bg=yellow;fg=white');
     }
 }
Ejemplo n.º 12
0
 /**
  * @Route("/admin/contract/{id}", defaults={"_format" = "pdf" })
  */
 public function indexAction(Student $student)
 {
     // Get contract by studentId or by contactId
     $contracts = $student->getContracts();
     $currentExpiry = NULL;
     foreach ($contracts as $contract) {
         if ($contract->getContractExpiry() > $currentExpiry) {
             $currentExpiry = $contract->getContractExpiry();
             $latestContract = $contract;
         }
     }
     $s = new String();
     $paymentTerms = $latestContract->getPaymentTerms();
     ld($paymentTerms);
     exit;
     $installments = $s->stringifyPayments($latestContract->getChargesAsArray());
     if (!$latestContract) {
         throw new \Exception('No contract for student');
     }
     // Get contract school and school state
     $school = $latestContract->getSchool();
     $cts = $latestContract->getMembershipType()->getContractTemplates();
     // ld($latestContract->getMembershipType());
     $contractTemplate = $cts->last();
     if ($contractTemplate) {
         $template = $contractTemplate->getTemplate();
         $org = $this->session->get('tsk_organization_id');
         $facade = $this->get('ps_pdf.facade');
         $response = new Response();
         $stringRenderer = $this->get('tsk.twig.string');
         $output = $stringRenderer->render($template, array('contract' => $latestContract, 'school' => $school, 'org' => $org, 'blackBeltFee' => 495, 'student' => $student, 'installments' => '$installments'));
         // $xml = $response->getContent();
         $content = $facade->render($output);
         return new Response($content, 200, array('content-type' => 'application/pdf'));
         return array('of');
         exit;
     }
     $refundPolicy = $this->generateRefundPolicy($student->getContracts()->count(), $school->getContact()->getState()->getStateName(), $latestContract->getAmount());
     $cancelPolicy = $this->generateCancelPolicy($school->getContact()->getState()->getStateName());
     $format = $this->get('request')->get('_format');
     return $this->render('TSKContractBundle:Default:index.pdf.twig', array('contract' => $latestContract, 'school' => $school, 'orgName' => "Tiger Schulmann's Mixed Martial Arts Center", 'abbrOrgName' => 'TSMMA', 'blackBeltFee' => 495, 'student' => $student, 'refundPolicy' => $refundPolicy, 'cancelPolicy' => $cancelPolicy, 'installments' => $installments));
 }
Ejemplo n.º 13
0
 /**
  * parseProposition 
  * 
  * @param mixed $proposition 
  * @access public
  * @return array($rules, $rewards)
  */
 public function parse($array)
 {
     $proposition = $array['clause'];
     $proposition = preg_replace('/^IF /', '', $proposition);
     list($rules, $rewards) = preg_split('/ THEN /i', $proposition);
     $ruleParts = preg_split('/ and /i', $rules);
     foreach ($ruleParts as $rulePart) {
         list($fact, $comparator, $value) = preg_split('/\\s/', $rulePart);
         $rule = new Rule();
         $factRepo = $this->manager->getRepository('TSKRulerBundle:Fact');
         $myFact = $factRepo->findOneBy(array('name' => $fact));
         if (!$myFact) {
             throw new \Exception('No fact [' . $fact . ']');
         }
         $rule->setFact($myFact);
         $rule->setComparator($comparator);
         $rule->setValue($value);
         $myRules[] = $rule;
     }
     $rewardParts = preg_split('/ and /i', $rewards);
     foreach ($rewardParts as $rewardPart) {
         preg_match('/(\\w+)\\((\\w+)?\\)/', $rewardPart, $matches);
         if (count($matches) == 2) {
             $method = $matches[1];
             $meta = null;
         } else {
             if (count($matches) == 3) {
                 $method = $matches[1];
                 $meta = $matches[2];
             } else {
                 ld($matches);
                 print "nope [{$rewardPart}]" . count($matches);
                 exit;
             }
         }
         $reward = new Reward();
         $reward->setMethod($method);
         $reward->setMetaData($meta);
         $myRewards[] = $reward;
     }
     return array($myRules, $myRewards);
 }
Ejemplo n.º 14
0
 public function package_edit($package_id = null)
 {
     $errors = false;
     if (!empty($package_id)) {
         $data = $this->Packages_model->get_package_by_id($package_id);
         foreach ($this->pg_language->languages as $lang_id => $lang_data) {
             $validate_lang[$lang_id] = l('package_name_' . $data["id"], 'packages', $lang_id);
         }
     } else {
         $data = array();
     }
     if ($this->input->post('btn_save')) {
         $post_data = array("gid" => $this->input->post("gid", true), "status" => $this->input->post("status", true), "price" => $this->input->post("price", true), "pay_type" => $this->input->post("pay_type", true), "available_days" => $this->input->post("available_days", true), "langs" => $this->input->post("langs", true));
         $validate_data = $this->Packages_model->validate_package($package_id, $post_data);
         $langs = $validate_data["langs"];
         if (!empty($validate_data["errors"])) {
             $errors = $validate_data["errors"];
             $validate_lang = $langs;
             $data = array_merge($data, $validate_data["data"]);
         } else {
             $this->Packages_model->save_package($package_id, $validate_data["data"], $langs);
             $this->system_messages->add_message('success', l('success_update_package_data', 'packages'));
             redirect(site_url() . "admin/packages/index");
         }
     }
     ///// languages
     $this->template_lite->assign('languages', $this->pg_language->languages);
     $this->template_lite->assign('languages_count', count($this->pg_language->languages));
     $this->template_lite->assign('cur_lang', $this->pg_language->current_lang_id);
     $this->template_lite->assign('pay_type_lang', ld('pay_type', 'services'));
     if (!empty($validate_lang)) {
         $this->template_lite->assign('validate_lang', $validate_lang);
     }
     $this->template_lite->assign('data', $data);
     if (!empty($errors)) {
         $this->system_messages->add_message('error', $errors);
     }
     $this->Menu_model->set_menu_active_item('admin_payments_menu', 'packages_menu_item');
     $this->system_messages->set_data('header', l('admin_header_packages_list', 'packages'));
     $this->template_lite->view('edit_package');
 }
Ejemplo n.º 15
0
 public function build()
 {
     $script = '';
     foreach ($this->getUrlToFileTable() as $path) {
         $script .= $this->compile($path) . PHP_EOL;
     }
     if (!$this->isMinify) {
         file_put_contents($this->filename, $script);
         return;
     }
     $output = "{$this->tmp}/bin/";
     if (!file_exists($output)) {
         File::makeDirectory($output, 0777, true);
     }
     if (!file_exists(dirname($this->filename))) {
         ld($this->filename);
         File::makeDirectory(dirname($this->filename), 0777, true);
     }
     $output .= basename($this->filename);
     file_put_contents($output, $script);
     File::copy($this->minify($output), $this->filename);
 }
Ejemplo n.º 16
0
 /**
  * @Then /^there are these messages:$/
  */
 public function thereAreTheseMessages(TableNode $table)
 {
     $messagesReaded = unserialize($this->data);
     $messages = array();
     foreach ($table->getHash() as $row) {
         $messages[$row['language']] = array('message' => $row['message'], 'is' => false);
     }
     foreach ($messagesReaded as $language => $data) {
         if (!isset($messages[$language])) {
             throw new \Exception(sprintf('message %s readed is not present in DB', $language));
         } else {
             if ($data['message'] != $messages[$language]['message']) {
                 ld($data, $messages[$language]);
                 throw new \Exception(sprintf('message %s readed present but diferent', $language));
             }
             $messages[$language]['is'] = true;
         }
     }
     foreach ($messages as $language => $data) {
         if (!$data['is']) {
             throw new \Exception(sprintf('message %s in DB but is not readed', $language));
         }
     }
 }
Ejemplo n.º 17
0
 /**
  * @Route("/regenerate-project-info/{projectId}", name="regenerate_project_info")
  */
 public function regenerateProjectInfoAction($projectId)
 {
     $this->init();
     $projectInfo = $this->translationsManager->regenerateProjectInfo($projectId);
     ld($projectInfo->getBundles());
     die("done!");
 }
Ejemplo n.º 18
0
 public function field_edit($type, $section, $id = null)
 {
     if (empty($type)) {
         $type = $this->Field_editor_model->get_default_editor_type();
     }
     $this->Field_editor_model->initialize($type);
     $this->template_lite->assign('type', $type);
     $this->template_lite->assign('type_settings', $this->Field_editor_model->get_settings());
     $validate_data['data'] = array();
     if (!empty($id)) {
         $data = $this->Field_editor_model->get_field_by_id($id);
         foreach ($this->pg_language->languages as $lang_id => $lang_data) {
             $validate_lang[$lang_id] = $this->Field_editor_model->format_field_name($data, $lang_id);
         }
         $section = $data["section_gid"];
     } else {
         $data['gid'] = $this->Field_editor_model->get_field_gid();
         $data["field_type"] = "text";
     }
     $this->template_lite->assign('section', $section);
     $section_data = $this->Field_editor_model->get_section_by_gid($section);
     $this->template_lite->assign('section_data', $section_data);
     if ($this->input->post('btn_save')) {
         if ($id) {
             $flag = "change";
             $field_type = $data["field_type"];
             $post_data = array("settings_data" => $this->input->post("settings_data", true), "fts" => $this->input->post("fts", true));
         } else {
             $flag = "add";
             $post_data = array("gid" => $this->input->post("gid", true), "section_gid" => $section, "editor_type_gid" => $type, "field_type" => $this->input->post("field_type", true), "fts" => $this->input->post("fts", true));
             $field_type = $this->input->post("field_type", true);
         }
         $langs = $this->input->post("langs", true);
         $validate_data = $this->Field_editor_model->validate_field($id, $field_type, $post_data, $langs);
         if (!empty($validate_data["errors"])) {
             $this->system_messages->add_message('error', $validate_data["errors"]);
             $validate_lang = $langs;
         } else {
             if ($flag == "change") {
                 $validate_data["data"]["gid"] = $data["gid"];
                 $validate_data["data"]["field_type"] = $data["field_type"];
             } else {
                 $params["where"]["section_gid"] = $section;
                 $validate_data["data"]["sorter"] = $this->Field_editor_model->get_fields_count($params) + 1;
             }
             $id = $this->Field_editor_model->save_field($id, $type, $section, $validate_data["data"], $validate_data['lang']);
             $this->system_messages->add_message('success', l('success_update_section_data', 'field_editor'));
             if ($flag == "add") {
                 redirect(site_url() . "admin/field_editor/field_edit/" . $type . "/" . $section . "/" . $id);
             } else {
                 redirect(site_url() . "admin/field_editor/fields/" . $type . "/" . $section);
             }
         }
     }
     $validate_data['data'] = array_merge($validate_data['data'], $data);
     ///// languages
     $this->template_lite->assign('languages', $this->pg_language->languages);
     $this->template_lite->assign('languages_count', count($this->pg_language->languages));
     $this->template_lite->assign('cur_lang', $this->pg_language->current_lang_id);
     if (!empty($validate_lang)) {
         $this->template_lite->assign('validate_lang', $validate_lang);
     }
     if ($id) {
         $this->template_lite->assign('type_block_content', $this->_get_field_type_block($data["field_type"], $data));
     }
     $this->template_lite->assign('data', $validate_data["data"]);
     $this->template_lite->assign('field_type_lang', ld('field_type', 'field_editor'));
     $this->Menu_model->set_menu_active_item('admin_fields_menu', 'fields_list_item');
     $this->system_messages->set_data('header', l('admin_header_fields_list', 'field_editor'));
     $this->template_lite->view('edit_fields');
 }
Ejemplo n.º 19
0
 /**
  * Render spam type edit page
  * @param integer $type_id
  */
 public function types_edit($type_id)
 {
     $this->load->model("spam/models/Spam_type_model");
     $data = $this->Spam_type_model->get_type_by_id($type_id);
     if ($this->input->post("btn_save")) {
         $post_data = $this->input->post("data", true);
         $validate_data = $this->Spam_type_model->validate_type($type_id, $post_data);
         if (!empty($validate_data["errors"])) {
             $return["error"] = implode("<br>", $validate_data["errors"]);
             $this->system_messages->add_message("success", l("success_updated_type", "spam"));
         } else {
             $this->Spam_type_model->save_type($type_id, $validate_data["data"]);
             $this->system_messages->add_message("success", l("success_updated_type", "spam"));
             $url = site_url() . "admin/spam/types";
             redirect($url);
         }
         $data = array_merge($data, $post_data);
     }
     $this->template_lite->assign("data", $data);
     $this->template_lite->assign("form_type_lang", ld("form_type", "spam"));
     $this->config->load("date_formats", TRUE);
     $date_format = $this->config->item("st_format_date_time_literal", "date_formats");
     $this->template_lite->assign("date_format", $date_format);
     $this->system_messages->set_data("header", l("admin_header_types_edit", "spam"));
     $this->Menu_model->set_menu_active_item("admin_spam_menu", "spam_types_item");
     $this->template_lite->view("types_edit");
 }
Ejemplo n.º 20
0
 public function template_edit($template_id = null)
 {
     if (!empty($template_id)) {
         $data = $this->Services_model->get_template_by_id($template_id);
         foreach ($this->pg_language->languages as $lang_id => $lang_data) {
             $validate_lang[$lang_id] = l('template_name_' . $data["id"], 'services', $lang_id);
         }
     } else {
         $data = array();
     }
     if ($this->input->post('btn_save')) {
         $post_data = array("gid" => $this->input->post("gid", true), "callback_module" => $this->input->post("callback_module", true), "callback_model" => $this->input->post("callback_model", true), "callback_buy_method" => $this->input->post("callback_buy_method", true), "callback_activate_method" => $this->input->post("callback_activate_method", true), "callback_validate_method" => $this->input->post("callback_validate_method", true), "price_type" => $this->input->post("price_type", true), "moveable" => $this->input->post("moveable", true), "data_admin" => unserialize($this->input->post("data_admin", true)), "data_user" => unserialize($this->input->post("data_user", true)), "lds" => unserialize($this->input->post("lds", true)));
         $langs = $this->input->post("langs", true);
         $validate_data = $this->Services_model->validate_template($template_id, $post_data);
         if (!empty($validate_data["errors"])) {
             $this->system_messages->add_message('error', $validate_data["errors"]);
             $validate_lang[] = $langs;
         } else {
             $this->Services_model->save_template($template_id, $validate_data["data"], $langs);
             $this->system_messages->add_message('success', l('success_update_template_data', 'services'));
             redirect(site_url() . "admin/services/templates");
         }
     }
     // languages
     $this->template_lite->assign('languages', $this->pg_language->languages);
     $this->template_lite->assign('languages_count', count($this->pg_language->languages));
     $this->template_lite->assign('cur_lang', $this->pg_language->current_lang_id);
     $this->template_lite->assign('price_type_lang', ld('price_type', 'services'));
     if (!empty($validate_lang)) {
         $this->template_lite->assign('validate_lang', $validate_lang);
     }
     $this->template_lite->assign('data', $data);
     $this->Menu_model->set_menu_active_item('admin_payments_menu', 'services_menu_item');
     $this->system_messages->set_data('header', l('admin_header_templates_list', 'services'));
     $this->template_lite->view('edit_templates');
 }
Ejemplo n.º 21
0
 public function settings()
 {
     $this->load->model('notifications/models/Sender_model');
     $data = array('mail_charset' => $this->pg_module->get_module_config('notifications', 'mail_charset'), 'mail_protocol' => $this->pg_module->get_module_config('notifications', 'mail_protocol'), 'mail_mailpath' => $this->pg_module->get_module_config('notifications', 'mail_mailpath'), 'mail_smtp_host' => $this->pg_module->get_module_config('notifications', 'mail_smtp_host'), 'mail_smtp_user' => $this->pg_module->get_module_config('notifications', 'mail_smtp_user'), 'mail_smtp_pass' => $this->pg_module->get_module_config('notifications', 'mail_smtp_pass'), 'mail_smtp_port' => $this->pg_module->get_module_config('notifications', 'mail_smtp_port'), 'mail_useragent' => $this->pg_module->get_module_config('notifications', 'mail_useragent'), 'mail_from_email' => $this->pg_module->get_module_config('notifications', 'mail_from_email'), 'mail_from_name' => $this->pg_module->get_module_config('notifications', 'mail_from_name'));
     // Check if openssl extension is loaded. It is required for DKIM.
     $openssl_loaded = extension_loaded('openssl');
     if ($openssl_loaded) {
         $data['dkim_private_key'] = $this->pg_module->get_module_config('notifications', 'dkim_private_key');
         $data['dkim_domain_selector'] = $this->pg_module->get_module_config('notifications', 'dkim_domain_selector');
         $this->template_lite->assign('openssl_loaded', true);
     }
     if ($this->input->post('btn_save')) {
         $post_data = array('mail_charset' => $this->input->post('mail_charset', true), 'mail_protocol' => $this->input->post('mail_protocol', true), 'mail_mailpath' => $this->input->post('mail_mailpath', true), 'mail_smtp_host' => $this->input->post('mail_smtp_host', true), 'mail_smtp_user' => $this->input->post('mail_smtp_user', true), 'mail_smtp_pass' => $this->input->post('mail_smtp_pass', true), 'mail_smtp_port' => $this->input->post('mail_smtp_port', true), 'mail_useragent' => $this->input->post('mail_useragent', true), 'mail_from_email' => $this->input->post('mail_from_email', true), 'mail_from_name' => $this->input->post('mail_from_name', true));
         $validate_data = $this->Sender_model->validate_mail_config($post_data);
         if (!empty($validate_data["errors"])) {
             $this->system_messages->add_message('error', $validate_data["errors"]);
             $data['mail_charset'] = $post_data["data"]['mail_charset'];
             $data['mail_protocol'] = $post_data["data"]['mail_protocol'];
             $data['mail_mailpath'] = $post_data["data"]['mail_mailpath'];
             $data['mail_smtp_host'] = $post_data["data"]['mail_smtp_host'];
             $data['mail_smtp_user'] = $post_data["data"]['mail_smtp_user'];
             $data['mail_smtp_pass'] = $post_data["data"]['mail_smtp_pass'];
             $data['mail_smtp_port'] = $post_data["data"]['mail_smtp_port'];
             $data['mail_useragent'] = $post_data["data"]['mail_useragent'];
             $data['mail_from_email'] = $post_data["data"]['mail_from_email'];
             $data['mail_from_name'] = $post_data["data"]['mail_from_name'];
         } else {
             foreach ($validate_data["data"] as $setting => $value) {
                 $this->pg_module->set_module_config('notifications', $setting, $value);
             }
             $this->system_messages->add_message('success', l('success_settings_saved', 'notifications'));
             $data['mail_charset'] = $validate_data["data"]['mail_charset'];
             $data['mail_protocol'] = $validate_data["data"]['mail_protocol'];
             $data['mail_mailpath'] = $validate_data["data"]['mail_mailpath'];
             $data['mail_smtp_host'] = $validate_data["data"]['mail_smtp_host'];
             $data['mail_smtp_user'] = $validate_data["data"]['mail_smtp_user'];
             $data['mail_smtp_pass'] = $validate_data["data"]['mail_smtp_pass'];
             $data['mail_smtp_port'] = $validate_data["data"]['mail_smtp_port'];
             $data['mail_useragent'] = $validate_data["data"]['mail_useragent'];
             $data['mail_from_email'] = $validate_data["data"]['mail_from_email'];
             $data['mail_from_name'] = $validate_data["data"]['mail_from_name'];
         }
     }
     if ($this->input->post('btn_dkim')) {
         $post_data = array('dkim_private_key' => $this->input->post('dkim_private_key', true), 'dkim_domain_selector' => $this->input->post('dkim_domain_selector', true));
         $validate_data = $this->Sender_model->validate_mail_config($post_data);
         if (!empty($validate_data["errors"])) {
             $this->system_messages->add_message('error', $validate_data["errors"]);
             $data['dkim_private_key'] = $post_data["data"]['dkim_private_key'];
             $data['dkim_domain_selector'] = $post_data["data"]['dkim_domain_selector'];
         } else {
             foreach ($validate_data["data"] as $setting => $value) {
                 $this->pg_module->set_module_config('notifications', $setting, $value);
             }
             $this->system_messages->add_message('success', l('success_settings_saved', 'notifications'));
             $data['dkim_private_key'] = $validate_data["data"]['dkim_private_key'];
             $data['dkim_domain_selector'] = $validate_data["data"]['dkim_domain_selector'];
         }
     }
     if ($this->input->post('btn_test')) {
         $post_data = array('mail_to_email' => $this->input->post('mail_to_email', true));
         $validate_data = $this->Sender_model->validate_test($post_data);
         if (!empty($validate_data["errors"])) {
             $this->system_messages->add_message('error', $validate_data["errors"]);
             $data["mail_to_email"] = $validate_data["data"]["mail_to_email"];
         } else {
             $result = $this->Sender_model->send_letter($validate_data["data"]["mail_to_email"], 'TEST ALERT', 'TEST ALERT', 'text');
             if ($result === true) {
                 $this->system_messages->add_message('success', l('success_send_test', 'notifications'));
             } else {
                 $this->system_messages->add_message('error', implode("\n", $result));
             }
         }
     }
     $this->template_lite->assign('protocol_lang', ld('protocol', 'notifications'));
     $this->template_lite->assign('settings_data', $data);
     $this->Menu_model->set_menu_active_item('admin_notifications_menu', 'nf_settings_item');
     $this->system_messages->set_data('header', l('admin_header_settings_edit', 'notifications'));
     $this->template_lite->view('settings');
 }
Ejemplo n.º 22
0
 function exc($message, $quiet = false)
 {
     $e = new \Exception($message);
     le($e->getMessage());
     ld($e->getTraceAsString());
     if (!$quiet) {
         throw $e;
     }
 }
Ejemplo n.º 23
0
 * file that was distributed with this source code.
 *
 * @author Daniel González <*****@*****.**>
 */
//build test data outside of timing loop
$data = [];
for ($i = 1; $i <= 10000; $i++) {
    $data[$i] = md5($i);
}
$timer = new \Desarrolla2\Timer\Timer(new \Desarrolla2\Timer\Formatter\Human());
for ($i = 1; $i <= 10000; $i++) {
    $cache->set($data[$i], $data[$i], 3600);
}
$timer->mark('10.000 set');
for ($i = 1; $i <= 10000; $i++) {
    $cache->has($data[$i]);
}
$timer->mark('10.000 has');
for ($i = 1; $i <= 10000; $i++) {
    $cache->get($data[$i]);
}
$timer->mark('10.000 get');
for ($i = 1; $i <= 10000; $i++) {
    $cache->has($data[$i]);
    $cache->get($data[$i]);
}
$timer->mark('10.000 has+get combos');
$benchmarks = $timer->getAll();
foreach ($benchmarks as $benchmark) {
    ld($benchmark);
}
Ejemplo n.º 24
0
 /**
  * Sitemap management
  *
  * @return void 
  */
 public function site_map()
 {
     if ($this->input->post('btn_save_sitexml')) {
         $params = array("changefreq" => $this->input->post('changefreq', true), "lastmod" => intval($this->input->post('lastmod', true)), "lastmod_date" => $this->input->post('lastmod_date', true), "priority" => intval($this->input->post('priority', true)));
         $this->pg_module->set_module_config('seo_advanced', 'sitemap_changefreq', $params['changefreq']);
         $this->pg_module->set_module_config('seo_advanced', 'sitemap_lastmod', $params['lastmod']);
         $this->pg_module->set_module_config('seo_advanced', 'sitemap_priority', $params['priority']);
         $generate_log = $this->Seo_advanced_model->generate_sitemap_xml($params);
         if (!empty($generate_log["errors"])) {
             $this->system_messages->add_message('error', $generate_log["errors"]);
         } else {
             $this->system_messages->add_message('success', l('sitemap_xml_success_generated', 'seo_advanced'));
         }
     }
     $sitemap_data = $this->Seo_advanced_model->get_sitemap_data();
     if (!empty($sitemap_data["errors"])) {
         $this->system_messages->add_message('error', $sitemap_data["errors"]);
     }
     $sitemap_data["data"]["current_date"] = date('Y-m-d H:i:s');
     $this->template_lite->assign('sitemap_data', $sitemap_data["data"]);
     $this->template_lite->assign('frequency_lang', ld('map_xml_frequency', 'seo_advanced'));
     $sitemap_changefreq = $this->pg_module->get_module_config('seo_advanced', 'sitemap_changefreq');
     $this->template_lite->assign('sitemap_changefreq', $sitemap_changefreq);
     $sitemap_lastmod = $this->pg_module->get_module_config('seo_advanced', 'sitemap_lastmod');
     $this->template_lite->assign('sitemap_lastmod', $sitemap_lastmod);
     $sitemap_priority = $this->pg_module->get_module_config('seo_advanced', 'sitemap_priority');
     $this->template_lite->assign('sitemap_priority', $sitemap_priority);
     $date_format = $this->pg_date->get_format('date_time_literal', 'st');
     $this->template_lite->assign('date_format', $date_format);
     $this->system_messages->set_data('back_link', site_url() . 'admin/seo_advanced');
     $this->system_messages->set_data('header', l('admin_header_sitemap', 'seo_advanced'));
     $this->template_lite->view('edit_site_map_form');
 }
Ejemplo n.º 25
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
$set = new Idatha\Set();
$element1 = new stdClass(1);
$element2 = new stdClass(2);
$element3 = new stdClass(3);
$element4 = new stdClass(4);
$element5 = new stdClass(5);
$set->add($element1);
$set->add($element2);
ld($set->isMember($element1), $set->isMember($element2), $set->isMember(new stdClass(1)));
$set2 = new Idatha\Set();
$set2->add($element2);
$set2->add($element3);
$set2->add($element4);
ld($set->union($set2)->toArray());
ld($set->intersection($set2)->toArray());
ld($set2->complement($set)->toArray());
ld($set->isSubset($set2));
ld($set->isMember($element1), $set->isMember($element2), $set->isMember(new stdClass(1)));
$subset = new Idatha\Set();
$subset->add($element1);
$subset->add($element2);
ld($set->isMember($element1), $set->isSubset($subset), $set->isSubset($subset, true));
Ejemplo n.º 26
0
 public function edit_place($id = null)
 {
     $this->load->model('banners/models/Banner_place_model');
     if ($id) {
         $data = $this->Banner_place_model->get($id);
     } else {
         $data = array();
     }
     if ($this->input->post('btn_save')) {
         $post_data = array("name" => $this->input->post("name", true), "keyword" => $this->input->post("keyword", true), "width" => $this->input->post("width", true), "height" => $this->input->post("height", true), "places_in_rotation" => $this->input->post("places_in_rotation", true), "rotate_time" => $this->input->post("rotate_time", true), "access" => $this->input->post("access", true), "place_groups" => $this->input->post("place_groups", true));
         $validate_data = $this->Banner_place_model->validate_place($id, $post_data);
         if (!empty($validate_data["errors"])) {
             $this->system_messages->add_message('error', $validate_data["errors"]);
             $data = array_merge($data, $validate_data["data"]);
         } else {
             $place_id = $this->Banner_place_model->save_place($id, $validate_data["data"]);
             $this->system_messages->add_message('success', l('success_update_place_data', 'banners'));
             redirect(site_url() . 'admin/banners/places_list');
         }
     }
     if ($id) {
         $data["place_groups"] = $this->Banner_place_model->get_place_group_ids($id);
     }
     $this->template_lite->assign('data', $data);
     $this->load->model('banners/models/Banner_group_model');
     $groups = $this->Banner_group_model->get_all_groups();
     if (!empty($groups) && !empty($data["place_groups"])) {
         foreach ($groups as $k => $group) {
             if (in_array($group["id"], $data["place_groups"])) {
                 $groups[$k]["selected"] = true;
             }
         }
     }
     $this->template_lite->assign('groups', $groups);
     $this->template_lite->assign('place_access_lang', ld('place_access', 'banners'));
     $this->Menu_model->set_menu_active_item('admin_banners_menu', 'places_list_item');
     $this->system_messages->set_data('header', l('admin_header_places_list', 'banners'));
     $this->template_lite->view('form_place');
 }
Ejemplo n.º 27
0
 protected function processAttendance($row)
 {
     if ($row) {
         $attendanceRepo = $this->manager->getRepository('TSK\\ScheduleBundle\\Entity\\ScheduleAttendance');
         $attDate = new \DateTime($row[3]);
         $classRepo = $this->manager->getRepository('TSK\\ClassBundle\\Entity\\Classes');
         $studentRepo = $this->manager->getRepository('TSK\\StudentBundle\\Entity\\Student');
         $class = $classRepo->find($row[1]);
         if (!$class) {
             print "Can't find class " . $row[1] . "\n";
             exit;
         }
         $student = $studentRepo->findOneBy(array('legacyStudentId' => $row[2]));
         if (!$student) {
             print "Can't find student " . $row[2] . "\n";
             exit;
         }
         $oldAttendance = $attendanceRepo->findOneBy(array('attDate' => $attDate, 'class' => $class, 'student' => $student));
         if (!$oldAttendance) {
             $attendance = new ScheduleAttendance();
             $attendance->setSchool($this->school);
             $attendance->setSchedule($this->dummyScheduleEntity);
             $attendance->setClass($class);
             $attendance->setStudent($student);
             $attendance->setAttDate($attDate);
             $attendance->setStatus('present');
             $attendance->setNotes($row[4]);
             try {
                 $this->manager->persist($attendance);
                 $this->manager->flush();
             } catch (DBALException $e) {
             } catch (\Exception $e) {
                 ld($e);
                 print $e->getMessage();
                 exit;
             }
         }
     }
 }
Ejemplo n.º 28
0
 /**
  * Does the same thing as the strftime but with multiple formats
  * and also translates month names and weekdays.
  *
  * @param string $template generic templaye
  * @param int $timestamp unix timestump
  * @param string $type format type (js | date | mysql | st | generic)
  * @return string
  */
 public function strftime($template, $timestamp = null, $type = 'st')
 {
     $time = getdate($timestamp);
     $translatable = array('week_day_full' => 'wday', 'week_day_short' => 'wday', 'month_full' => 'mon', 'month_short' => 'mon');
     $search = array();
     $replace = array();
     if ('generic' === $type) {
         $type = 'st';
         $template = str_replace(array('[', ']'), '', $template);
         $template = str_replace(array_keys($this->templates[$type]), array_values($this->templates[$type]), $template);
     }
     foreach ($translatable as $tpl_name => $time_name) {
         if (false !== strpos($template, $this->templates[$type][$tpl_name])) {
             $ds = ld($tpl_name, 'start');
             if (!empty($ds['option'][$time[$time_name]])) {
                 $search[] = $this->templates[$type][$tpl_name];
                 $replace[] = $ds['option'][$time[$time_name]];
             }
         }
     }
     // Translate
     if (count($replace)) {
         $template = str_replace($search, $replace, $template);
     }
     // Convert to st
     if ('st' !== $type && 'generic' !== $type) {
         $template = $this->convert_tpl($type, 'st', $template);
     }
     return strftime($template, $timestamp);
 }
Ejemplo n.º 29
0
 function watermark_edit($watermark_id = null)
 {
     if ($watermark_id) {
         $data = $this->Uploads_config_model->get_watermark_by_id($watermark_id);
     } else {
         $data["id"] = 0;
     }
     if ($this->input->post('btn_save')) {
         $post_data = array("name" => $this->input->post('name', true), "gid" => $this->input->post('gid', true), "position_hor" => $this->input->post('position_hor', true), "position_ver" => $this->input->post('position_ver', true), "alpha" => $this->input->post('alpha', true), "wm_type" => $this->input->post('wm_type', true), "img" => $_FILES['img'], "font_size" => $this->input->post('font_size', true), "font_color" => $this->input->post('font_color', true), "font_face" => $this->input->post('font_face', true), "font_text" => $this->input->post('font_text', true), "shadow_color" => $this->input->post('shadow_color', true), "shadow_distance" => $this->input->post('shadow_distance', true));
         $validate_data = $this->Uploads_config_model->validate_watermark($watermark_id, $post_data);
         if (!empty($validate_data["errors"])) {
             $this->system_messages->add_message('error', $validate_data["errors"]);
             $data = array_merge($data, $validate_data["data"]);
         } else {
             $data = $validate_data["data"];
             $this->Uploads_config_model->save_watermark($watermark_id, $data);
             $this->system_messages->add_message('success', $watermark_id ? l('success_updated_watermark', 'uploads') : l('success_added_watermark', 'uploads'));
             $url = site_url() . "admin/uploads/watermarks";
             redirect($url);
         }
     }
     $this->template_lite->assign('data', $this->Uploads_config_model->format_watermark($data));
     $this->template_lite->assign('lang_positions_hor', ld('wm_position_hor', 'uploads'));
     $this->template_lite->assign('lang_positions_ver', ld('wm_position_ver', 'uploads'));
     $this->template_lite->assign('lang_font_face', ld('wm_font_face', 'uploads'));
     $this->template_lite->assign('lang_wm_type', ld('wm_type', 'uploads'));
     $this->template_lite->assign('watermark_test', $this->Uploads_config_model->default_url . $this->Uploads_config_model->watermark_test_image);
     $this->template_lite->assign('wm_text_limits', $this->Uploads_config_model->wm_text_limits);
     $this->wm_clear_preview_data();
     $this->system_messages->set_data('header', l('admin_header_watermark_edit', 'uploads'));
     $this->system_messages->set_data('back_link', site_url() . 'admin/uploads/watermarks');
     $this->template_lite->view('edit_watermark');
 }
Ejemplo n.º 30
0
 /**
  * @Route("/crest")
  * @Template()
  * @Method({"GET"})
  */
 public function crestAction()
 {
     $ctx = new \Ruler\Context(array());
     $em = $this->getDoctrine()->getManager();
     $class = new \TSK\RankBundle\Ruler\RankReward($em, $ctx);
     $ref = new \ReflectionClass('\\TSK\\RankBundle\\Ruler\\RankReward');
     print $ref->getDocComment();
     ld($ref->getMethods());
     print 'howdy';
     return array('foo' => 'bar');
 }