Ejemplo n.º 1
0
 /**
  * Returns all messages in the given time frame between two parties.
  *
  * @return array Returns messages array
  * @author  
  */
 public function GetMsgs()
 {
     global $_;
     try {
         $sth = DB::prep("SELECT TIME_FORMAT(m1.time, '%k:%i') as time,IF(m1.type = 'admin', m3.username, m2.nick) as user_nick, m1.to_user as admin, m1.user as user_id, m1.type, m1.msg\r\n             FROM messaging AS m1 \r\n             LEFT JOIN messaging_users AS m2 ON m1.user = m2.user_id \r\n             LEFT JOIN messaging_admin m3 ON m1.to_user = m3.id \r\n             WHERE m1.user = :curr_user\r\n             ORDER BY m1.time");
         $sth->bindParam(":curr_user", $_SESSION['visitor_chat_user'], PDO::PARAM_INT);
         $result = DB::getAll($sth);
         foreach ($result as $key => $val) {
             $keys = $key ? $key - 1 : $key;
             $result[$key]['before'] = $result[$keys]['user_id'];
             $result[$key]['admin_before'] = $result[$keys]['admin'];
             $result[$key]['type_before'] = $result[$keys]['type'];
             $result[$key]['msg'] = $this->UploadReplace($val['msg']);
             $result[$key]['msg'] = $this->makeClickableLinks($result[$key]['msg']);
             $result[$key]['msg'] = nl2br($result[$key]['msg']);
             $smiley = new Smiley();
             $actions = $smiley->ListSmiley();
             foreach ($actions as $val) {
                 $search[] = $val->sign;
                 $replace[] = '<img src="' . $_['MAIN_FOLDER'] . '/admin/images/smiley/' . $val->filename . '" />';
             }
             $result[$key]['msg'] = str_replace($search, $replace, $result[$key]['msg']);
             $result[$key]['msg'] = stripslashes($result[$key]['msg']);
         }
         $_SESSION['msg_update'] = time();
         return $result;
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
 /**
  *
  * @param type $smileyCount Number of smileys the text will contain.
  */
 protected function testReplaceSymbols_nSymbols($smileyCount)
 {
     $smiley = new Smiley(":-)", 'image.gif');
     $textBlocks = self::generateTextBlocks($smileyCount + 1);
     $text = implode($smiley->Symbol(), $textBlocks);
     $expected = implode($smiley->ImageTag(), $textBlocks);
     $result = $smiley->replaceSymbols($text);
     $this->assertEquals($expected, $result);
 }
Ejemplo n.º 3
0
 /**
  * Smiley short notation as defined in database
  */
 static function short($markup, $matches)
 {
     $smileys = Smiley::getShort();
     $name    = $smileys[$matches[2]];
     return isset($name)
         ? $matches[1] . Smiley::img($name) . $matches[3]
         : $matches[0];
 }
Ejemplo n.º 4
0
 /**
  * Extends this controller with neccessary infobox
  *
  * @param String $view Currently viewed group
  */
 private function setSidebar($view)
 {
     $sidebar = Sidebar::Get();
     $sidebar->setImage('sidebar/smiley-sidebar.png');
     $sidebar->setTitle(PageLayout::getTitle() ?: _('Smileys'));
     // Render items
     $factory = new Flexi_TemplateFactory($this->dispatcher->trails_root . '/views/admin/smileys/');
     $actions = new ActionsWidget();
     $actions->addLink(_('Neues Smiley hochladen'), $this->url_for('admin/smileys/upload', $view), Icon::create('add', 'clickable'))->asDialog('size=auto');
     $actions->addLink(_('Smileys zählen'), $this->url_for('admin/smileys/count', $view), Icon::create('code', 'clickable'));
     $actions->addLink(_('Tabelle aktualisieren'), $this->url_for('admin/smileys/refresh', $view), Icon::create('refresh', 'clickable'));
     $actions->addLink(_('Smiley-Übersicht öffnen'), URLHelper::getLink('dispatch.php/smileys'), Icon::create('smiley', 'clickable'))->asDialog();
     $sidebar->addWidget($actions);
     $widget = new SidebarWidget();
     $filter = $factory->render('selector', array('characters' => Smiley::getUsedCharacters(), 'controller' => $this, 'view' => $view));
     $widget->setTitle(_('Filter'));
     $widget->addElement(new WidgetElement($filter));
     $sidebar->addWidget($widget);
     $widget = new SidebarWidget();
     $statistics = $factory->render('statistics', Smiley::getStatistics());
     $widget->setTitle(_('Statistiken'));
     $widget->addElement(new WidgetElement($statistics));
     $sidebar->addWidget($widget);
 }
Ejemplo n.º 5
0
 /**
  * calls Stud.IP's kill_format and additionally removes any found smiley-tag
  *
  * @param string $text the text to parse
  * @return string the text without format-tags and without smileys
  */
 static function killFormat($text)
 {
     $text = kill_format($text);
     // find stuff which is enclosed between to colons
     preg_match('/:.*:/U', $text, $matches);
     // remove the match if it is a smiley
     foreach ($matches as $match) {
         if (Smiley::getByName($match) || Smiley::getByShort($match)) {
             $text = str_replace($match, '', $text);
         }
     }
     return $text;
 }
Ejemplo n.º 6
0
?>

<ul class="smiley-tabs" role="navigation">
<? if ($favorites_activated): ?>
    <li class="favorites <? if ($view === 'favorites') echo 'current'; ?>">
        <a href="<?php 
echo $controller->url_for('smileys/index/favorites');
?>
" data-dialog>
            <?php 
echo _('Favoriten');
?>
        </a>
    </li>
<? endif; ?>
<? if (Smiley::getShort()): ?>
    <li <? if ($view === 'short') echo 'class="current"'; ?>>
        <a href="<?php 
echo $controller->url_for('smileys/index/short');
?>
" data-dialog>
            <?php 
echo _('Kürzel');
?>
        </a>
    </li>
<? endif; ?>
    <li <? if ($view === 'all') echo 'class="current"'; ?>>
        <a href="<?php 
echo $controller->url_for('smileys/index/all');
?>
Ejemplo n.º 7
0
 /**
  * Method called for pre-parse processing.
  * @param	string	$text	The input text.
  * @return	string	The text that will be parsed.
  */
 public function onStart($text)
 {
     // process of smileys and other special characters
     if ($this->getParam('convertSmileys')) {
         $text = Smiley::convertSmileys($text);
     }
     if ($this->getParam('convertSymbols')) {
         $text = Smiley::convertSymbols($text);
     }
     // if a specific pre-parse function was defined, it is called
     $func = $this->getParam('preParseFunction');
     if (isset($func)) {
         $text = $func($text);
     }
     return $text;
 }
Ejemplo n.º 8
0
 /**
  * Synchronizes the smileys' file system or an atomic file with the
  * database.
  * The smiley directory is scanned for new, changed or missing files.
  * Any difference will change the database's record.
  *
  * This method is also used for uploading new smileys. Provide an
  * absolute filename of a smiley and it will either be imported into
  * the database or the database will be adjusted to the current file's
  * dimensions.
  *
  * @param mixed $smiley_file If no filename is provided, the whole file
  *                           system is refreshed
  * @return Array Numbers: inserted, updated, removed (, favorites adjusted)
  */
 static function refresh($smiley_file = null)
 {
     $counts = array('insert' => 0, 'update' => 0);
     if ($filename === null) {
         $files = glob(self::getFilename('*'));
     } else {
         $files = array($smiley_file);
     }
     foreach ($files as $file) {
         $image_info = getimagesize($file);
         if ($image_info[2] !== IMAGETYPE_GIF) {
             continue;
         }
         $name = substr(basename($file), 0, strrpos(basename($file), "."));
         //$name = basename($file, '.gif');
         $smiley = Smiley::getByName($name);
         $update = false;
         if (!$smiley->id) {
             $smiley->name = $name;
             $smiley->short = array_search($name, $GLOBALS['SMILE_SHORT']) ?: '';
             $smiley->width = $image_info[0];
             $smiley->height = $image_info[1];
             $update = true;
             $counts['insert'] += 1;
         } else {
             if ($smiley->width + $smiley->height != $image_info[0] + $image_info[1]) {
                 $smiley->width = $image_info[0];
                 $smiley->height = $image_info[1];
                 $update = true;
                 $counts['update'] += 1;
             }
         }
         //$smiley->width || $smiley->width = 20;
         //$smiley->height || $smiley->height = 20;
         if ($update) {
             $smiley->store();
         }
         $ids[] = $smiley->id;
     }
     $db_ids = self::getGrouped('all', self::FETCH_ID);
     $missing = array_diff($db_ids, $ids);
     self::Remove($missing);
     $counts['delete'] = count($missing);
     if (SmileyFavorites::isEnabled()) {
         $counts['favorites'] = SmileyFavorites::gc();
     }
     return $counts;
 }
Ejemplo n.º 9
0
 /**
  * Back end for the smiley picker javascript module.
  * Renders a list of smileys very similar to the index action but
  * unfortunately still to different to be combined.
  *
  * @param mixed $view Subset to display, defaults to favorites if enabled
  * @param int   $page Section of subset to display
  */
 function picker_action($view = null, $page = 0)
 {
     $per_page = self::GRID_WIDTH * self::GRID_HEIGHT;
     $this->view = $view ?: ($this->default === 'favorites' ? 'favorites' : 'all');
     $smileys = $this->view == 'favorites' ? Smiley::getByIds($this->favorites->get()) : Smiley::getGrouped($this->view);
     $this->page = $page;
     $this->pages = floor(count($smileys) / $per_page);
     array_walk($smileys, function ($smiley) {
         $smiley->link = Smiley::getURL($smiley->name);
         $smiley->html = Smiley::img($smiley->name);
     });
     $this->smileys = array_slice($smileys, $page * $per_page, $per_page);
     $this->characters = Smiley::getUsedCharacters();
 }
Ejemplo n.º 10
0
echo URLHelper::getLink('dispatch.php/smileys');
?>
" data-dialog>
        <?php 
echo _('Smileys');
?>
    </a> |
    <a href="<?php 
echo format_help_url("Basis.VerschiedenesFormat");
?>
" target="new"><?php 
echo _("Formatierungshilfen");
?>
</a>
    <br>
    <? $smileys = Smiley::getByIds($sm->get()) ?>
    <? if (!empty($smileys)) : ?>
        <? foreach ($smileys as $smiley) : ?>
            <img class="js" src="<?php 
echo $smiley->getUrl();
?>
" data-smiley=" :<?php 
echo $smiley->name;
?>
: "
                style="cursor: pointer;" onClick="STUDIP.Forum.insertSmiley('<?php 
echo $textarea_id;
?>
', this)">
        <? endforeach ?>
    <? elseif ($GLOBALS['user']->id != 'nobody') : ?>
Ejemplo n.º 11
0
<?php

$smiley = new Smiley();
echo json_encode($smiley->ListSmiley());
Ejemplo n.º 12
0
 /**
  * Garbage collector. Removes all smiley ids from the users' favorites
  * that are no longer in the database.
  *
  * @return int Number of changed records
  */
 static function gc()
 {
     $smileys = Smiley::getGrouped('all', Smiley::FETCH_ID);
     $query = "SELECT user_id, smiley_favorite FROM user_info WHERE smiley_favorite != ''";
     $statement = DBManager::get()->prepare($query);
     $statement->execute(array());
     $temp = $statement->fetchGrouped(PDO::FETCH_COLUMN);
     $changed = 0;
     foreach ($temp as $user_id => $favorite_string) {
         $old_favorites = explode(',', $favorite_string);
         $new_favorites = array_intersect($smileys, $old_favorites);
         if (count($old_favorites) > count($new_favorites)) {
             $favorites = new self($user_id);
             $favorites->set($new_favorites);
             $changed += 1;
         }
     }
     return $changed;
 }