Beispiel #1
0
 public function configure(array $data)
 {
     $isXhr = $data['context']->getRequest()->isXmlHttpRequest();
     $uri = $this->cleanUri(dmArray::get($data['server'], 'PATH_INFO', $data['server']['REQUEST_URI']));
     $milliseconds = (microtime(true) - dm::getStartTime()) * 1000;
     $this->data = array('time' => (string) $data['server']['REQUEST_TIME'], 'uri' => dmString::truncate($uri, 500), 'code' => (string) $data['context']->getResponse()->getStatusCode(), 'app' => (string) sfConfig::get('sf_app'), 'env' => (string) sfConfig::get('sf_environment'), 'ip' => (string) $data['server']['REMOTE_ADDR'], 'user_id' => (string) $data['context']->getUser()->getUserId(), 'user_agent' => dmString::truncate($isXhr ? '' : isset($data['server']['HTTP_USER_AGENT']) ? $data['server']['HTTP_USER_AGENT'] : '', 500), 'xhr' => (int) $isXhr, 'mem' => (string) memory_get_peak_usage(true), 'timer' => (string) sprintf('%.0f', $milliseconds), 'cache' => sfConfig::get('dm_internal_page_cached'));
 }
Beispiel #2
0
 public function configure(array $data)
 {
     $userId = dmArray::get($data, 'user_id', $this->serviceContainer->getService('user')->getUserId());
     if (!$userId && dmConfig::isCli()) {
         $userId = 'task';
     }
     $this->data = array('time' => (string) $data['server']['REQUEST_TIME'], 'ip' => (string) $this->getCurrentRequestIp(), 'session_id' => (string) session_id(), 'user_id' => (string) $userId, 'action' => (string) $data['action'], 'type' => (string) $data['type'], 'subject' => dmString::truncate($data['subject'], 500), 'record' => isset($data['record']) ? get_class($data['record']) . ':' . $data['record']->get('id') : '');
 }
Beispiel #3
0
 public static function randomizeDirName($dir, $maxLen = 255)
 {
     $random = dmString::random(4);
     $strip_len = $maxLen - strlen($random);
     $strip_name = dmString::truncate(self::sanitizeDirName($file), $strip_len, "");
     $final_name = $strip_name . "-" . $random;
     return $final_name;
 }
Beispiel #4
0
 public function listenToConfigUpdatedEvent(sfEvent $event)
 {
     $setting = $event['setting'];
     if ('internal' == dmString::strtolower($setting->groupName)) {
         return;
     }
     $this->log(array('server' => $_SERVER, 'action' => 'update', 'type' => 'config', 'subject' => sprintf('%s = %s ( %s )', $setting->name, dmString::truncate($setting->value, 80), $event['culture'])));
 }
Beispiel #5
0
 protected function storeInDb(dmErrorDescription $error)
 {
     dmDb::create('DmError', array('description' => $error->name . "\n" . $error->exception->getTraceAsString(), 'php_class' => $error->class, 'name' => dmString::truncate($error->name, 255, ''), 'module' => $error->module, 'action' => $error->action, 'uri' => $error->uri, 'env' => $error->env))->save();
 }
Beispiel #6
0
echo _tag('h2.title', __('Menu'));
echo _tag('div.control_wrap.dm_box_inner', _tag('div.control', $controlMenu->render()));
echo _close('div');
// right
echo _open('div.center');
echo _open('ul.content.clearfix');
if ($folder->isRoot()) {
    echo _tag('li.parent_folder', _tag('a.root', _media('dmAdmin/images/media/up2.png')->size(64, 64)));
} else {
    echo _tag('li.parent_folder', _link($sf_context->getRouting()->getMediaUrl($folder->getNode()->getParent()))->text(_media('dmAdmin/images/media/up.png')->size(64, 64)->alt(__('Back to the parent folder'))));
}
if ($children = $folder->getNode()->getChildren()) {
    $arrChildren = array();
    foreach ($children as $f) {
        $arrChildren[$f->getName()] = $f;
    }
    ksort($arrChildren);
    foreach ($arrChildren as $f) {
        echo _tag('li.folder', _link($sf_context->getRouting()->getMediaUrl($f))->text(($f->isWritable() ? _media('dmAdmin/images/media/folder.png')->size(64, 64) : _media('dmAdmin/images/media/folder-locked.png')) . _tag('span.name', media_wrap_text($f->getName())) . _tag('span.more', format_number_choice('[0]no element|[1]1 element|(1,+Inf]%1% elements', array('%1%' => $f->getNbElements()), $f->getNbElements()))));
    }
}
foreach ($files as $f) {
    echo _tag('li.file.media_id_' . $f->getId(), $f->isImage() && $f->checkFileExists() ? _link($sf_context->getRouting()->getMediaUrl($f))->text(_tag('span.image_background', array('style' => sprintf('background: url("%s") top left no-repeat', _media($f)->size(128, 128)->quality(80)->getSrc())), _tag('span.name', media_wrap_text(dmString::truncate($f->getFile(), 40))))) : _link($sf_context->getRouting()->getMediaUrl($f))->text(media_file_image_tag($f) . _tag('span.name', media_wrap_text(dmString::truncate($f->getFile(), 40)))));
}
echo _close('ul');
echo _close('div');
// center
echo _close('div');
// list
echo _close('div');
echo _close('div');
Beispiel #7
0
        $parents[] = _tag("a#dmf" . $ancestor->get('id'), $ancestor->get('name'));
    }
}
$parents[] = _tag("a#dmf" . $folder->get('id'), $folder->get('name'));
echo _tag('div.breadCrumb', implode(" » ", $parents));
echo _open("ul.content.clearfix");
if ($folder->getNode()->hasParent()) {
    echo _tag("li.folder#dmf" . $folder->getNode()->getParent()->get('id'), _media('dmCore/images/media/up.png')->size(64, 64));
} else {
    echo _tag('li', _media('dmCore/images/media/up2.png')->size(64, 64));
}
if ($folders = $folder->getNode()->getChildren()) {
    $arrFolders = array();
    foreach ($folders as $f) {
        $arrFolders[$f->getName()] = $f;
    }
    ksort($arrFolders);
    foreach ($arrFolders as $f) {
        echo _tag("li.folder#dmf" . $f->get('id'), ($f->isWritable() ? _media('dmCore/images/media/folder.png')->size(64, 64) : _media('dmCore/images/media/folder-locked.png')->size(64, 64)) . _tag('span.name', media_wrap_text($f->get('name'))));
    }
}
foreach ($folder->getMedias() as $f) {
    echo _open('li.file#dmm' . $f->get('id') . '.' . $f->getMimeGroup());
    if ($f->isImage()) {
        echo _tag('span.image_background', array('style' => sprintf('background: url("%s") top left no-repeat', _media($f)->size(128, 128)->quality(80)->getSrc(false))), _tag("span.name", media_wrap_text(dmString::truncate($f->get('file'), 40))));
    } else {
        echo media_file_image_tag($f) . _tag("span.name", media_wrap_text(dmString::truncate($f->get('file'), 40)));
    }
    echo _close('li');
}
echo _close("ul");
 protected function renderUser(dmEventLogEntry $entry)
 {
     return sprintf('%s%s<br /><span class=light>%s</span>', ($username = $entry->get('username')) ? sprintf('<strong class="mr10">%s</strong>', dmString::escape(dmString::truncate($username, 20, '...'))) : '', $this->renderIp($entry->get('ip')), $entry->get('session_id'));
 }
Beispiel #9
0
<?php

use_helper('Date');
if (!isset($items)) {
    return;
}
echo _open('ul');
foreach ($items as $item) {
    echo _tag('li.clickable', _link($item->getLink())->text($item->getTitle())->set('.block') . _tag('span.quiet.little', format_date($item->getPubDate(), 'd/MM H:mm') . ' : ' . dmString::truncate(strip_tags($item->getDescription()), 400, _link($item->getLink())->text(' ...')->title(__('Read more')))));
}
echo _close('ul');
<?php

/*
 * Variables available :
 * - $query (string)        the searched query
 * - $form  (mySearchForm)  the search form
 * - $pager (dmSearchPager) the search pager
 */
if (!$pager) {
    echo _tag('h1.t_big', __('No results for "%1%"', array('%1%' => escape($query))));
} else {
    echo _tag('h1.t_big', __('Results %1% to %2% of %3%', array('%1%' => $pager->getFirstIndice(), '%2%' => $pager->getLastIndice(), '%3%' => $pager->getNbResults())));
}
echo $form->open('.big_search_form action=main/search method=get'), $form['query']->field('.big_search_field'), $form->submit('Search'), $form->close();
if (!$pager) {
    return;
}
echo $pager->renderNavigationTop();
echo _open('ol.search_results.clearfix start=' . $pager->getFirstIndice());
foreach ($pager->getResults() as $result) {
    echo _tag('li.search_result.clickable.ml20.mb5', _tag('span.score.mr10', ceil(100 * $result->getScore()) . '%') . _link($result->getPage())->text(_tag('strong', escape($result->getPage()->name))) . _tag('span.ml10', dmString::truncate($result->getPageContent(), 200)));
}
echo _close('ol');
echo $pager->renderNavigationBottom();
Beispiel #11
0
 protected function renderUserTime(dmEventLogEntry $entry)
 {
     $username = $entry->get('username');
     return ($username ? '<strong class="mr10">' . dmString::escape(dmString::truncate($username, 20, '...')) . '</strong><br />' : '') . $entry->get('ip');
 }
 protected function renderUserAndBrowser(dmRequestLogEntry $entry)
 {
     $browser = $entry->get('browser');
     return sprintf('<div class="browser %s">%s<br />%s %s</div>', $this->getBrowserIcon($browser), ($username = $entry->get('username')) ? '<strong class="mr5">' . dmString::escape(dmString::truncate($username, 20, '...')) . '</strong>' : $this->renderIp($entry->get('ip')), ucfirst($browser->getName()), $browser->getVersion());
 }
<?php

use_helper('Date');
/*
 * An $item is an array containing:
 * - title:       title of the feed item
 * - link:        url of the feed item
 * - content:     HTML content
 * - pub_date:    item publication date (timestamp)
 */
echo _open('ul');
foreach ($items as $item) {
    echo _tag('li.clickable', _link($item['link'])->text($item['title'])->set('.block') . _tag('span.quiet.little', format_date($item['pub_date'], 'd/MM H:mm') . ' by ' . trim($item['author_name'], ')') . '<br />' . dmString::truncate(strip_tags($item['content']), 100)));
}
echo _close('ul');
<?php

/*
 * Variables available :
 * - $query (string)        the searched query
 * - $form  (mySearchForm)  the search form
 * - $pager (dmSearchPager) the search pager
 */
if (!$pager) {
    echo _tag('h1', __('No results for "%1%"', array('%1%' => escape($query))));
    return;
}
echo _tag('h1', __('Results %1% to %2% of %3%', array('%1%' => $pager->getFirstIndice(), '%2%' => $pager->getLastIndice(), '%3%' => $pager->getNbResults())));
echo $pager->renderNavigationTop();
echo _open('ol.search_results start=' . $pager->getFirstIndice());
foreach ($pager as $result) {
    $page = $result->getPage();
    echo _tag('li.search_result', _tag('span.score', ceil(100 * $result->getScore()) . '%') . _link($page)->text(_tag('span.page_name', escape($page->name)) . dmString::truncate($result->getPageContent(), 200)));
}
echo _close('ol');
echo $pager->renderNavigationBottom();
 /**
  * Returns a shorter text of the guestbook entries,
  * to use in admin interface.
  *
  * @return string - short text
  */
 public function getShortText()
 {
     return dmString::truncate($this->getText(), 50);
 }
<?php

/*
 * An $item is an array containing:
 * - title:       title of the feed item
 * - link:        url of the feed item
 * - content:     HTML content
 * - pub_date:    item publication date (timestamp)
 * - author_name: author name
 * - author_link: author link
 * - author_email: author email
 */
echo _open('ul');
foreach ($items as $item) {
    echo _tag('li', _link($item['link'])->text($item['title'])->set('.feed_item_link') . _tag('div.feed_item_content', dmString::truncate(strip_tags($item['content']), 100)));
}
echo _close('ul');
Beispiel #17
0
 protected function renderUser(dmRequestLogEntry $entry)
 {
     return sprintf('%s%s', ($username = $entry->get('username')) ? sprintf('<strong class="mr10">%s</strong><br />', dmString::escape(dmString::truncate($username, 20, '...'))) : '', $this->renderIp($entry->get('ip')));
 }