public function add_topic_action() { if (!$GLOBALS['perm']->have_studip_perm("tutor", $_SESSION['SessionSeminar'])) { throw new AccessDeniedException(); } if (!Request::get("title")) { throw new Exception("Geben Sie einen Titel an."); } $date = new CourseDate(Request::option("termin_id")); $seminar_id = $date['range_id']; $title = studip_utf8decode(Request::get("title")); $topic = CourseTopic::findByTitle($seminar_id, $title); if (!$topic) { $topic = new CourseTopic(); $topic['title'] = $title; $topic['seminar_id'] = $seminar_id; $topic['author_id'] = $GLOBALS['user']->id; $topic['description'] = ""; $topic->store(); } $date->addTopic($topic); $factory = $this->get_template_factory(); $output = array('topic_id' => $topic->getId()); $template = $factory->open($this->get_default_template("_topic_li")); $template->set_attribute("topic", $topic); $template->set_attribute("date", $date); $output['li'] = $template->render(); $this->render_json($output); }
/** * Unescapes a string for use in .po file. * * @param String $string String to unescape * @return String Unescaped string */ function po_unescape($string) { $replaces = array('\\"' => '"', '\\n' => "\n"); $string = str_replace(array_keys($replaces), array_values($replaces), $string); $string = studip_utf8decode($string); return $string; }
/** * Things to do before every page load. */ public function before_filter(&$action, &$args) { parent::before_filter($action, $args); // AJAX request, so no page layout. if (Request::isXhr()) { $this->via_ajax = true; $this->set_layout(null); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } // Open base layout for normal } else { $layout = $GLOBALS['template_factory']->open('layouts/base'); $this->set_layout($layout); PageLayout::setTitle(_('Anmeldesets')); // Get only own courses if user doesn't have permission to edit institute-wide coursesets. $this->onlyOwnCourses = true; if ($GLOBALS['perm']->have_perm('admin') || $GLOBALS['perm']->have_perm('dozent') && get_config('ALLOW_DOZENT_COURSESET_ADMIN')) { // We have access to institute-wide course sets, so all courses may be assigned. $this->onlyOwnCourses = false; Navigation::activateItem('/tools/coursesets/sets'); } else { throw new AccessDeniedException(); } } PageLayout::addSqueezePackage('admission'); $this->set_content_type('text/html;charset=windows-1252'); $views = new ViewsWidget(); $views->setTitle(_('Aktionen')); $views->addLink(_('Anmeldeset anlegen'), $this->url_for('admission/courseset/configure'))->setActive($action == 'configure'); Sidebar::Get()->addWidget($views); }
/** * Construct an array object from a json string * * @param string $input a json string */ function __construct($input) { if (is_string($input)) { $input = studip_utf8decode((array) json_decode($input, true)); } parent::__construct((array) $input); }
/** * Before filter, set up the page by initializing the session and checking * all conditions. * * @param String $action Name of the action to be invoked * @param Array $args Arguments to be passed to the action method */ public function before_filter(&$action, &$args) { parent::before_filter($action, $args); if (!Config::Get()->LITERATURE_ENABLE) { throw new AccessDeniedException(_('Die Literaturverwaltung ist nicht aktiviert.')); } $this->attributes['textarea'] = array('style' => 'width:98%', 'rows' => 2); $this->attributes['select'] = array(); $this->attributes['date'] = array(); $this->attributes['combo'] = array('style' => 'width:45%; display: inline;'); $this->attributes['lit_select'] = array('style' => 'font-size:8pt;width:100%'); // on AJAX request set no page layout. if (Request::isXhr()) { $this->via_ajax = true; $this->set_layout(null); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } } $this->set_content_type('text/html;charset=windows-1252'); /* checkObject(); // do we have an open object? checkObjectModule('literature'); object_set_visit_module('literature');/**/ }
/** * common tasks for all actions */ function before_filter(&$action, &$args) { global $perm; parent::before_filter($action, $args); if (Request::get('termin_id')) { $this->dates[0] = new SingleDate(Request::option('termin_id')); $this->course_id = $this->dates[0]->range_id; } if (Request::get('issue_id')) { $this->issue_id = Request::option('issue_id'); $this->dates = array_values(array_map(function ($data) { $d = new SingleDate(); $d->fillValuesFromArray($data); return $d; }, IssueDB::getDatesforIssue(Request::option('issue_id')))); $this->course_id = $this->dates[0]->range_id; } if (!get_object_type($this->course_id, array('sem')) || SeminarCategories::GetBySeminarId($this->course_id)->studygroup_mode || !$perm->have_studip_perm("tutor", $this->course_id)) { throw new Trails_Exception(400); } PageLayout::setHelpKeyword("Basis.VeranstaltungenVerwaltenAendernVonZeitenUndTerminen"); PageLayout::setTitle(Course::findCurrent()->getFullname() . " - " . _("Veranstaltungstermine absagen")); $this->set_content_type('text/html;charset=windows-1252'); if (Request::isXhr()) { $this->set_layout(null); $this->response->add_header('X-Title', PageLayout::getTitle()); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } } }
/** * You can specify a custom import. * @return bool */ public function fetchData() { $wsdl = FleximportConfig::get("SEMIRO_SOAP_PARTICIPANTS_WSDL"); $soap = new SoapClient($wsdl, array('trace' => 1, 'exceptions' => 0, 'cache_wsdl' => $GLOBALS['CACHING_ENABLE'] || !isset($GLOBALS['CACHING_ENABLE']) ? WSDL_CACHE_BOTH : WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)); $file = strtolower(substr($wsdl, strrpos($wsdl, "/") + 1)); $soapHeaders = new SoapHeader($file, 'Header', array('pw' => FleximportConfig::get("SEMIRO_SOAP_PASSWORD"))); $soap->__setSoapHeaders($soapHeaders); $result = $soap->getTeilnehmerXML(array('pw' => FleximportConfig::get("SEMIRO_SOAP_PASSWORD"))); if (is_a($result, "SoapFault")) { throw new Exception("SOAP-error: " . $result->faultstring); } $fields = array(); $doc = new DOMDocument(); $doc->loadXML(studip_utf8decode($result->return)); $seminar_data = array(); foreach ($doc->getElementsByTagName("teilnehmer") as $seminar) { $seminar_data_row = array(); foreach ($seminar->childNodes as $attribute) { if ($attribute->tagName) { if (!in_array(studip_utf8decode(trim($attribute->tagName)), $fields)) { $fields[] = studip_utf8decode(trim($attribute->tagName)); } $seminar_data_row[] = studip_utf8decode(trim($attribute->nodeValue)); } } $seminar_data[] = $seminar_data_row; } $this->table->createTable($fields, $seminar_data); }
function edit_action($area_id) { ForumPerm::check('edit_area', $this->getId(), $area_id); if (Request::isAjax()) { ForumEntry::update($area_id, studip_utf8decode(Request::get('name')), studip_utf8decode(Request::get('content'))); $this->render_json(array('content' => ForumEntry::killFormat(ForumEntry::killEdit(studip_utf8decode(Request::get('content')))))); } else { ForumEntry::update($area_id, Request::get('name'), Request::get('content')); $this->flash['messages'] = array('success' => _('Die Änderungen am Bereich wurden gespeichert.')); $this->redirect(PluginEngine::getLink('coreforum/index/index')); } }
public function store_action($version) { $body = Request::get('body'); if (Request::isXhr()) { $body = studip_utf8decode($body); } submitWikiPage($this->keyword, $version, $body, $GLOBALS['user']->id, $this->range_id); $latest_version = getLatestVersion($this->keyword, $this->range_id); if (Request::isXhr()) { $this->render_json(array('version' => $latest_version['version'], 'body' => $latest_version['body'], 'messages' => implode(PageLayout::getMessages()) ?: false, 'zusatz' => getZusatz($latest_version))); } else { // Yeah, wait for the whole trailification of the wiki... } }
/** * common tasks for all actions */ function before_filter(&$action, &$args) { $this->current_action = $action; parent::before_filter($action, $args); if (Request::isXhr()) { $this->set_layout(null); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } } else { $this->set_layout($GLOBALS['template_factory']->open('layouts/base')); } $this->set_content_type('text/html;charset=windows-1252'); }
/** * common tasks for all actions */ function before_filter(&$action, &$args) { parent::before_filter($action, $args); $this->course_id = $args[0]; if (!in_array($action, words('apply claim delete order_down order_up'))) { $this->redirect($this->url_for('/apply/' . $action)); return false; } if (!get_object_type($this->course_id, array('sem'))) { throw new Trails_Exception(400); } $course = Seminar::GetInstance($this->course_id); $enrolment_info = $course->getEnrolmentInfo($GLOBALS['user']->id); //Ist bereits Teilnehmer/Admin/freier Zugriff -> gleich weiter if ($enrolment_info['enrolment_allowed'] && (in_array($enrolment_info['cause'], words('root courseadmin member')) || $enrolment_info['cause'] == 'free_access' && $GLOBALS['user']->id == 'nobody')) { $redirect_url = UrlHelper::getUrl('seminar_main.php', array('auswahl' => $this->course_id)); if (Request::isXhr()) { $this->response->add_header('X-Location', $redirect_url); $this->render_nothing(); } else { $this->redirect($redirect_url); } return false; } //Grundsätzlich verboten if (!$enrolment_info['enrolment_allowed']) { throw new AccessDeniedException($enrolment_info['description']); } PageLayout::setTitle($course->getFullname() . " - " . _("Veranstaltungsanmeldung")); PageLayout::addSqueezePackage('enrolment'); if (Request::isXhr()) { $this->set_layout(null); $this->response->add_header('X-No-Buttons', 1); $this->response->add_header('X-Title', PageLayout::getTitle()); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } } else { $this->set_layout($GLOBALS['template_factory']->open('layouts/base')); } $this->set_content_type('text/html;charset=windows-1252'); if (Request::submitted('cancel')) { $this->redirect(URLHelper::getURL('dispatch.php/course/details/', array('sem_id' => $this->course_id))); } }
function before_filter(&$action, &$args) { $this->current_action = $action; // allow only "word" characters in arguments $this->validate_args($args); parent::before_filter($action, $args); if ($this->with_session) { # open session page_open(array('sess' => 'Seminar_Session', 'auth' => $this->allow_nobody ? 'Seminar_Default_Auth' : 'Seminar_Auth', 'perm' => 'Seminar_Perm', 'user' => 'Seminar_User')); // show login-screen, if authentication is "nobody" $GLOBALS['auth']->login_if((Request::get('again') || !$this->allow_nobody) && $GLOBALS['user']->id == 'nobody'); // Setup flash instance $this->flash = Trails_Flash::instance(); // set up user session include 'lib/seminar_open.php'; } # Set base layout # # If your controller needs another layout, overwrite your controller's # before filter: # # class YourController extends AuthenticatedController { # function before_filter(&$action, &$args) { # parent::before_filter($action, $args); # $this->set_layout("your_layout"); # } # } # # or unset layout by sending: # # $this->set_layout(NULL) # $layout_file = Request::isXhr() ? 'layouts/dialog.php' : 'layouts/base.php'; $layout = $GLOBALS['template_factory']->open($layout_file); $this->set_layout($layout); if ($this->encoding) { $this->set_content_type('text/html;charset=' . $this->encoding); } if (Request::isXhr() && $this->utf8decode_xhr) { $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } } }
/** * @see AuthenticatedController::before_filter */ public function before_filter(&$action, &$args) { parent::before_filter($action, $args); if (Request::isXhr()) { $this->via_ajax = true; $this->set_layout(null); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } } else { $layout = $GLOBALS['template_factory']->open('layouts/base'); $this->set_layout($layout); PageLayout::setTitle(_('Anmeldesets')); Navigation::activateItem('/tools/coursesets'); } $this->set_content_type('text/html;charset=windows-1252'); }
/** * Callback function being called before an action is executed. */ function before_filter(&$action, &$args) { parent::before_filter($action, $args); // AJAX request, so no page layout. if (Request::isXhr()) { $this->via_ajax = true; $this->set_layout(null); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } // Open base layout for normal view } else { $layout = $GLOBALS['template_factory']->open('layouts/base'); $this->set_layout($layout); } $this->set_content_type('text/html;charset=windows-1252'); $this->help_admin = $GLOBALS['perm']->have_perm('root') || RolePersistence::isAssignedRole($GLOBALS['user']->id, 'Hilfe-Administrator(in)'); }
/** * @see AuthenticatedController::before_filter */ public function before_filter(&$action, &$args) { parent::before_filter($action, $args); if (Request::isXhr()) { $this->via_ajax = true; $this->set_layout(null); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } } else { $this->via_ajax = false; $layout = $GLOBALS['template_factory']->open('layouts/base'); $this->set_layout($layout); PageLayout::setTitle(_('Verwaltung von Anmelderegeln')); Navigation::activateItem('/admin/config/admissionrules'); } PageLayout::addSqueezePackage('admission'); $this->set_content_type('text/html;charset=windows-1252'); }
/** * @todo Adjust this to db BEFORE release */ public function load($identifier, $variables = array(), $language = null) { $language = $language ?: substr($GLOBALS['user']->preferred_language, 0, 2); $jsonfile = sprintf('%s/%s/%s.json', $this->json_directory, strtolower($language), $identifier); if (!file_exists($jsonfile) && $language !== 'de') { $language = 'de'; $jsonfile = sprintf('%s/%s/%s.json', $this->json_directory, strtolower($language), $identifier); } if (!file_exists($jsonfile) || !is_readable($jsonfile)) { throw new InvalidArgumentException('Helpbar for identifier "' . $identifier . '" not found or not readable.'); } $json = studip_utf8decode(json_decode(file_get_contents($jsonfile), true)); if ($json === null) { throw new RuntimeException('Helpbar content for identifier "' . $identifier . '" could not be loaded.'); } foreach ($json as $row) { if (!empty($row['icon'])) { $icon = Icon::create($row['icon'], 'info_alt'); } $this->addPlainText($row['label'] ?: '', $this->interpolate($row['text'], $variables), $icon ?: null); } }
/** * @see AuthenticatedController::before_filter */ public function before_filter(&$action, &$args) { parent::before_filter($action, $args); if (Request::isXhr()) { $this->via_ajax = true; $this->set_layout(null); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } } else { $layout = $GLOBALS['template_factory']->open('layouts/base'); $this->set_layout($layout); PageLayout::setTitle(_('Personenlisten')); Navigation::activateItem('/tools/coursesets/userlists'); } PageLayout::addSqueezePackage('admission'); $this->set_content_type('text/html;charset=windows-1252'); $views = new ViewsWidget(); $views->setTitle(_('Aktionen')); $views->addLink(_('Personenliste anlegen'), $this->url_for('admission/userlist/configure'))->setActive($action == 'configure'); Sidebar::Get()->addWidget($views); }
public function process_action($process_id) { if (Request::isPost()) { if (Request::submitted("start")) { $protocol = array(); $starttime = time(); $this->process = FleximportProcess::find($process_id); $this->tables = $this->process->tables; foreach ($this->tables as $table) { $table->fetchData(); } foreach ($this->tables as $table) { $table->doImport(); } $duration = time() - $starttime; if ($duration >= 60) { PageLayout::postMessage(MessageBox::success(sprintf(_("Import wurde durchgeführt und dauerte %s Minuten"), floor($duration / 60)), $protocol)); } else { PageLayout::postMessage(MessageBox::success(_("Import wurde durchgeführt"), $protocol)); } } elseif ($_FILES['tableupload']) { foreach ($_FILES['tableupload']['tmp_name'] as $table_id => $tmp_name) { if ($tmp_name) { $table = new FleximportTable($table_id); $output = $this->plugin->getCSVDataFromFile($tmp_name); if ($table['tabledata']['source_encoding'] === "utf8") { $output = studip_utf8decode($output); } $headline = array_shift($output); $table->createTable($headline, $output); } } PageLayout::postMessage(MessageBox::success(_("CSV-Datei hochgeladen"))); } } $this->redirect("import/overview/" . $process_id); }
public function post_files_action() { $context = Request::option("context") ? Request::get("context") : $GLOBALS['user']->id; $context_type = Request::option("context_type"); if (!Request::isPost() || $context_type === "course" && !$GLOBALS['perm']->have_studip_perm("autor", $context)) { throw new AccessDeniedException("Kein Zugriff"); } //check folders $db = DBManager::get(); $folder_id = md5("Blubber_" . $context . "_" . $GLOBALS['user']->id); $parent_folder_id = md5("Blubber_" . $context); if ($context_type !== "course") { $folder_id = $parent_folder_id; } $folder = $db->query("SELECT * " . "FROM folder " . "WHERE folder_id = " . $db->quote($folder_id) . " " . "")->fetch(PDO::FETCH_COLUMN, 0); if (!$folder) { $folder = $db->query("SELECT * " . "FROM folder " . "WHERE folder_id = " . $db->quote($parent_folder_id) . " " . "")->fetch(PDO::FETCH_COLUMN, 0); if (!$folder) { $db->exec("INSERT IGNORE INTO folder " . "SET folder_id = " . $db->quote($parent_folder_id) . ", " . "range_id = " . $db->quote($context) . ", " . "user_id = " . $db->quote($GLOBALS['user']->id) . ", " . "name = " . $db->quote("BlubberDateien") . ", " . "permission = '7', " . "mkdate = " . $db->quote(time()) . ", " . "chdate = " . $db->quote(time()) . " " . ""); } if ($context_type === "course") { $db->exec("INSERT IGNORE INTO folder " . "SET folder_id = " . $db->quote($folder_id) . ", " . "range_id = " . $db->quote($parent_folder_id) . ", " . "user_id = " . $db->quote($GLOBALS['user']->id) . ", " . "name = " . $db->quote(get_fullname()) . ", " . "permission = '7', " . "mkdate = " . $db->quote(time()) . ", " . "chdate = " . $db->quote(time()) . " " . ""); } } $output = array(); foreach ($_FILES as $file) { $GLOBALS['msg'] = ''; if ($context_type === "course") { validate_upload($file); if ($GLOBALS['msg']) { $output['errors'][] = $file['name'] . ': ' . studip_utf8encode(html_entity_decode(trim(substr($GLOBALS['msg'], 6), '§'))); continue; } } if ($file['size']) { $document['name'] = $document['filename'] = studip_utf8decode(strtolower($file['name'])); $document['user_id'] = $GLOBALS['user']->id; $document['author_name'] = get_fullname(); $document['seminar_id'] = $context; $document['range_id'] = $context_type === "course" ? $folder_id : $parent_folder_id; $document['filesize'] = $file['size']; if ($newfile = StudipDocument::createWithFile($file['tmp_name'], $document)) { $type = null; strpos($file['type'], 'image') === false || ($type = "img"); strpos($file['type'], 'video') === false || ($type = "video"); if (strpos($file['type'], 'audio') !== false || strpos($document['filename'], '.ogg') !== false) { $type = "audio"; } $url = GetDownloadLink($newfile->getId(), $newfile['filename']); if ($type) { $output['inserts'][] = "[" . $type . "]" . $url; } else { $output['inserts'][] = "[" . $newfile['filename'] . "]" . $url; } } } } $this->render_json($output); }
/** * @see lib/classes/Config::fetchData() */ protected function fetchData($data = null) { if ($data !== null) { $this->data = $data; } else { $this->data = array(); foreach (Config::get()->getFields('user') as $field) { $this->data[$field] = Config::get()->{$field}; $metadata[$field] = Config::get()->getMetadata($field); } $db = DbManager::get(); $rs = $db->query("SELECT field, value FROM user_config WHERE user_id = " . $db->quote($this->user_id)); while ($row = $rs->fetch(PDO::FETCH_ASSOC)) { switch ($metadata[$row['field']]['type']) { case 'integer': $value = (int) $row['value']; break; case 'boolean': $value = (bool) $row['value']; break; case 'array': $value = studip_utf8decode((array) json_decode($row['value'], true)); break; default: $value = $row['value']; } $this->data[$row['field']] = $value; } } }
public function rename_sem_type_action() { $sem_type = $GLOBALS['SEM_TYPE'][Request::get("sem_type")]; if ($sem_type) { $sem_type->set('name', studip_utf8decode(Request::get("name"))); $sem_type->store(); } $this->render_nothing(); }
/** * Initialize Stud.IP metadata array for creating a new Stud.IP document. * * @param array $file Metadata of uploaded file. * @param string $folder_id ID of folder in which the document is created. * @return array Stud.IP document metadata */ static function studipData($file, $folder_id) { $filename = \studip_utf8decode($file['name']); return array('name' => $filename, 'filename' => $filename, 'user_id' => $GLOBALS['user']->id, 'author_name' => \get_fullname(), 'seminar_id' => WysiwygRequest::seminarId(), 'range_id' => $folder_id, 'filesize' => $file['size']); }
/** * Call HTMLPurifier to create safe HTML. * * @param string $dirty_html Unsafe or 'uncleaned' HTML code. * @return string Clean and safe HTML code. */ public static function purify($dirty_html) { // remember created purifier so it doesn't have to be created again static $purifier = NULL; if ($purifier === NULL) { $purifier = self::createPurifier(); } return studip_utf8decode($purifier->purify(studip_utf8encode($dirty_html))); }
/** * edit one room requests in a dialog */ public function edit_dialog_action() { if (Request::isXhr()) { $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } if ($this->course_id != '-') { $this->edit_action(); $title = PageLayout::getTitle(); } else { $sem_create_data =& $_SESSION['sem_create_data']; if (Request::option('new_room_request_type')) { if ($sem_create_data['room_requests'][Request::option('new_room_request_type')] instanceof RoomRequest) { $request = clone $sem_create_data['room_requests'][Request::option('new_room_request_type')]; } else { $request = new RoomRequest(); $request->seminar_id = '-'; $request->user_id = $GLOBALS['user']->id; list($new_type, $id) = explode('_', Request::option('new_room_request_type')); if ($new_type == 'date') { $request->termin_id = Request::option('new_room_request_type'); } elseif ($new_type == 'cycle') { $request->metadate_id = Request::option('new_room_request_type'); } } $room_request_form_attributes = self::process_form($request, $sem_create_data['sem_turnout']); $this->search_result = $room_request_form_attributes['search_result']; $this->search_by_properties = $room_request_form_attributes['search_by_properties']; $this->admission_turnout = $sem_create_data['sem_turnout']; $this->request = $request; $room_categories = array_values(array_filter(getResourcesCategories(), create_function('$a', 'return $a["is_room"] == 1;'))); if (!$request->getCategoryId() && count($room_categories) == 1) { $request->setCategoryId($room_categories[0]['category_id']); } $this->room_categories = $room_categories; $this->new_room_request_type = Request::option('new_room_request_type'); $this->is_resources_admin = getGlobalPerms($GLOBALS['user']->id); $title = _("Verwaltung von Raumanfragen"); if (Request::submitted('save') || Request::submitted('save_close')) { if ($request->getSettedPropertiesCount() || $request->getResourceId()) { $sem_create_data['room_requests'][Request::option('new_room_request_type')] = $request; $this->request_stored = true; if (Request::submitted('save')) { PageLayout::postMessage(MessageBox::success(_("Die Raumanfrage und gewünschte Raumeigenschaften wurden gespeichert"))); } } else { PageLayout::postMessage(MessageBox::error(_("Die Anfrage kann noch nicht gespeichert werden, da Sie mindestens einen Raum oder mindestens eine Eigenschaft (z.B. Anzahl der Sitzplätze) angeben müssen!"))); } } $old_request = $sem_create_data['room_requests'][Request::option('new_room_request_type')]; if (!is_object($old_request) || $request->category_id != $old_request->category_id || $request->resource_id != $old_request->resource_id || $request->getProperties() != $old_request->getProperties() || $request->comment != $old_request->comment) { PageLayout::postMessage(MessageBox::info(_("Die Änderungen an der Raumanfrage wurden noch nicht gespeichert!"))); } } } if (Request::submitted('save_close') && isset($this->request_stored)) { return $this->render_json(array('auto_close' => true, 'auto_reload' => $this->request_stored)); } else { $this->render_template('course/room_requests/edit_dialog.php', null); $this->flash->discard(); $content = $this->get_response()->body; $this->erase_response(); return $this->render_json(array('title' => studip_utf8encode($title), 'content' => studip_utf8encode($content))); } } else { return $this->render_text(''); } }
/** * Encodes a string or array from UTF-8 to Stud.IP encoding * (WINDOWS-1252/ISO-8859-1 with numeric HTML-ENTITIES) * * @stolenfrom Stud.IP v2.4 * * @param mixed $data a string in UTF-8 or an array with all strings encoded in utf-8 * @return string the string in WINDOWS-1252/HTML-ENTITIES */ static function utf8decode($data) { if (is_array($data)) { $new_data = array(); foreach ($data as $key => $value) { $key = studip_utf8decode($key); $new_data[$key] = $value = self::utf8decode($value); } return $new_data; } elseif (is_string($data)) { if(!preg_match('/[\200-\377]/', $data)){ return $data; } else { $windows1252 = array( "\x80" => '€', "\x81" => '�', "\x82" => '‚', "\x83" => 'ƒ', "\x84" => '„', "\x85" => '…', "\x86" => '†', "\x87" => '‡', "\x88" => 'ˆ', "\x89" => '‰', "\x8A" => 'Š', "\x8B" => '‹', "\x8C" => 'Œ', "\x8D" => '�', "\x8E" => 'Ž', "\x8F" => '�', "\x90" => '�', "\x91" => '‘', "\x92" => '’', "\x93" => '“', "\x94" => '”', "\x95" => '•', "\x96" => '–', "\x97" => '—', "\x98" => '˜', "\x99" => '™', "\x9A" => 'š', "\x9B" => '›', "\x9C" => 'œ', "\x9D" => '�', "\x9E" => 'ž', "\x9F" => 'Ÿ'); return str_replace( array_values($windows1252), array_keys($windows1252), utf8_decode(mb_encode_numericentity( $data, array(0x100, 0xffff, 0, 0xffff), 'UTF-8' )) ); } } else { return $data; } }
/** * fetch config data from table config * pass array to override database access * @param array $data */ protected function fetchData($data = null) { if ($data !== null) { $this->data = $data; } else { $this->data = array(); $db = DbManager::get(); $rs = $db->query("SELECT field, value, type, section, `range`, description, comment, is_default FROM `config` ORDER BY is_default DESC, section, field"); while ($row = $rs->fetch(PDO::FETCH_ASSOC)) { // set the the type of the default entry for the modified entry if (!empty($this->metadata[$row['field']])) { $row['type'] = $this->metadata[$row['field']]['type']; } switch ($row['type']) { case 'integer': $value = (int) $row['value']; break; case 'boolean': $value = (bool) $row['value']; break; case 'array': $value = studip_utf8decode((array) json_decode($row['value'], true)); break; default: $value = (string) $row['value']; $row['type'] = 'string'; } $this->data[$row['field']] = $value; $this->metadata[$row['field']] = array_intersect_key($row, array_flip(words('type section range description is_default comment'))); $this->metadata[$row['field']]['field'] = $row['field']; } } }
/** * Fetches information from the url by getting the contents of the * webpage, parse the webpage and extract the information from the * opengraph meta-tags. * If the site doesn't have any opengraph-metatags it is in fact no * opengraph node and thus no data will be stored in the database. * Only $url['is_opengraph'] === '0' indicates that the site is no * opengraph node at all. * * @todo The combination of parse_link() and the following request * leads to two requests for the open graph data. This should * be fixed due to performance reasons. */ public function fetch() { if (!Config::get()->OPENGRAPH_ENABLE) { return; } $response = parse_link($this['url']); if ($response['response_code'] == 200 && strpos($response['Content-Type'], 'html') !== false) { if (preg_match('/(?<=charset=)[^;]*/i', $response['Content-Type'], $match)) { $currentEncoding = $match[0]; } else { $currentEncoding = 'ISO-8859-1'; } $context = stream_context_create(array('http' => array('method' => 'GET', 'header' => sprintf("User-Agent: Stud.IP v%s OpenGraph Parser\r\n", $GLOBALS['SOFTWARE_VERSION'])))); $content = file_get_contents($this['url'], false, $context); $content = mb_encode_numericentity($content, array(0x80, 0xffff, 0, 0xffff), $currentEncoding); $old_libxml_error = libxml_use_internal_errors(true); $doc = new DOMDocument(); $doc->loadHTML($content); libxml_use_internal_errors($old_libxml_error); $metatags = $doc->getElementsByTagName('meta'); $reservedTags = array('url', 'chdate', 'mkdate', 'last_update', 'is_opengraph', 'data'); $isOpenGraph = false; $ogTags = array(); $data = array(); foreach ($metatags as $tag) { $key = false; if ($tag->hasAttribute('property') && strpos($tag->getAttribute('property'), 'og:') === 0) { $key = strtolower(substr($tag->getAttribute('property'), 3)); } if (!$key && $tag->hasAttribute('name') && strpos($tag->getAttribute('name'), 'og:') === 0) { $key = strtolower(substr($tag->getAttribute('name'), 3)); } if ($key) { $content = studip_utf8decode($tag->getAttribute('content')); $data[] = array('og:' . $key => $content); $ogTags[$key] = $content; $isOpenGraph = true; } } foreach ($ogTags as $key => $tag) { if ($this->isField($key) && !in_array($key, $reservedTags)) { $this[$key] = $tag; } } if (!$this['title'] && $isOpenGraph) { $titles = $doc->getElementsByTagName('title'); if ($titles->length > 0) { $this['title'] = studip_utf8decode($titles->item(0)->textContent); } } if (!$this['description'] && $isOpenGraph) { foreach ($metatags as $tag) { if (stripos($tag->getAttribute('name'), "description") !== false || stripos($tag->getAttribute('property'), "description") !== false) { $this['description'] = studip_utf8decode($tag->getAttribute('content')); } } } $this['data'] = $data; } $this['is_opengraph'] = (int) $isOpenGraph; }
/** * Uses the given data to fill the object values. This can be used * as a generic function for storing data if the concrete rule type * isn't known in advance. * * @param Array $data * @return AdmissionRule This object. */ public function setAllData($data) { if ($data['start_date'] && !$data['start_time']) { $data['start_time'] = strtotime($data['start_date']); } if ($data['end_date'] && !$data['end_time']) { $data['end_time'] = strtotime($data['end_date'] . ' 23:59:59'); } $this->message = $data['ajax'] ? studip_utf8decode($data['message']) : $data['message']; $this->startTime = $data['start_time']; $this->endTime = $data['end_time']; return $this; }
function utf8_decode_array_values($ar) { if (is_array($ar)) { $decoded = array(); foreach ($ar as $key => $value) { if (!is_array($value)) { $decoded[$key] = studip_utf8decode($value); } else { $decoded[$key] = $this->utf8_decode_array_values($value); } } return $decoded; } else { return null; } }
echo $model->id; ?> ][]" title="<?php echo _('Monat'); ?> " <? if ($model->is_required) echo 'required'; ?>> <option value=""></option> <? for ($i = 0; $i < 12; $i += 1): ?> <option value="<?php echo $i + 1; ?> " <? if ($value && date('n', $timestamp) == $i + 1) echo 'selected'; ?>> <?php echo studip_utf8decode(strftime('%B', strtotime('Januar 1st +' . $i . ' months'))); ?> </option> <? endfor;?> </select> <input type="text" name="<?php echo $name; ?> [<?php echo $model->id; ?> ][]" maxlength="4" size="3" value="<? if ($value) echo date('Y', $timestamp); ?>" title="<?php