Hosting na mieru už od 5,5 Eur od spoločnosti WebSupport.sk
Hosting sponzoruje spoločnosť WebSupport.sk

Kopa snippetou

V tejto téme sa nachádzajú snippety (rozšírenia) pre Etomite.

Moderátor: Moderators

Kopa snippetou

Poslaťod churchyard » Uto Júl 03, 2007 1:59 pm

tak sem se rozhodl, ze publiknu vsecko co mam, pokud to pujde, uvedu i autora...
co snippet, to post

// EDIT: typos
Naposledy upravil churchyard dňa Pia Júl 06, 2007 11:45 am, celkovo upravené 1
  • The Neverhood - Československý web o Neverhoodovi
  • P.R.D.I. - nejlepší folkrock široko daleko
  • Yozzefy - hudební gulášek známých písní
Obrázok užívateľa
churchyard
Czech LT
Czech LT
 
Príspevky: 181
Registrovaný: Ned Nov 06, 2005 3:40 pm
Bydlisko: Praha [CZ]

AntiSpam

Poslaťod churchyard » Uto Júl 03, 2007 2:18 pm

[[AntiSpam]]
autor dutch
Zamezí robotickému zkopírování emailové adresy nebo Jabber ID.
Známé problémy: Neporadí si to s nestandardními znaky v JID. Jako je například ^ v _rasel^
Demo: http://neverhood.etomite.sk/kontakt.htm
Kód: Vybrať všetko
/*
name: [[AntiSpam]]
usage: [[AntiSpam?email=nekdo@nekde.net]] nebo [[AntiSpam?jabber=TRUE&email=nekdo@jabber.org]]
author: dutch (+ chucryard dodelal jabber)
*/

$output = '';
$email_mask = '^[a-zA-Z0-9_\-\+]+(\.[a-zA-z0-9_\-\+]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*\.[a-zA-Z]{2,4}$';

if($jabber) { // cesky JID
$lang["email"] = "Toto JID je chráněno proti spamu (není to e-mail!)";
$lang["neplatny"] = "Zadané JID není platné!";
$lang["nezadan"] = "Nebylo zadáno JID!";
$prefix = "xmpp:";
}
else { // cesky mail
$lang["email"] = "Tento e-mail je chráněn proti spamu";
$lang["neplatny"] = "Zadaný e-mail není platný!";
$lang["nezadan"] = "Nebyl zadán e-mail!";
$prefix = "mailto:";
}

/* ZAKOMENTOVANY SLOVENSKY LANG
if($jabber) { // slovenksy JID
$lang["email"] = "Toto JID je chránené proti spamu (nie je to e-mail!)";
$lang["neplatny"] = "Zadané JID nie je platné!";
$lang["nezadan"] = "Nebolo zadané JID!";
$prefix = "xmpp:";
}
else { // slovensky mail
$lang["email"] = "Tento e-mail je chránený proti spamu";
$lang["neplatny"] = "Zadaný e-mail nie je platný!";
$lang["nezadan"] = "Nebyl zadaný e-mail!";
$prefix = "mailto:";
} */

if (!$email) {
  $output .= $lang["nezadan"];
} else {
  if (eregi($email_mask ,$email)) {
    $email_transform = strrev($email);
    $output .= '<a href="' . $prefix . $email_transform . '" onclick="\'mailReverse(this)\'" rel="nofollow"><bdo title="' . $lang["email"] . '" dir="rtl">' . $email_transform . '</bdo></a>';
  } else {
    $output .= $lang["neplatny"];
  }
}

return $output;
Naposledy upravil churchyard dňa Uto Júl 03, 2007 2:29 pm, celkovo upravené 1
  • The Neverhood - Československý web o Neverhoodovi
  • P.R.D.I. - nejlepší folkrock široko daleko
  • Yozzefy - hudební gulášek známých písní
Obrázok užívateľa
churchyard
Czech LT
Czech LT
 
Príspevky: 181
Registrovaný: Ned Nov 06, 2005 3:40 pm
Bydlisko: Praha [CZ]

EasyPeasyGallery

Poslaťod churchyard » Uto Júl 03, 2007 2:28 pm

[[EasyPeasyGallery]]
autor Nick_NP
čeština by churchyard
slovenčina by spade
Zobrazí všecky obrázky ze složky, náhled musíte dodělat sami.
Demo: http://neverhood.etomite.sk/galvideo.htm
Postup:
  1. Vytvoříte složku s dvěma podsložkama: thumbs a large
  2. Náhledy se stejnými názvy jako mají originály nahrajte do složky thumbs a originály do large
  3. Pak jen zavoláte snippet [[EasyPeasyGallery?directory=/nejaka/slozka]]
Kód: Vybrať všetko
/*
name: [[EasyPeasyGallery]]
author: Nick_NP
usage:
   1. Vytvoříte složku s dvěma podsložkama: "thumbs" a "large"
   2. Náhledy se stejnými názvy jako mají originály nahrajte do složky "thumbs" a originály do "large"
   3. Pak jen zavoláte snippet [[EasyPeasyGallery?directory=/nejaka/slozka]]
*/

// LANGUAGE
$lang['prev'] = "předchozí";
$lang['next'] = "další";
$lang['omluva'] = "Omlouváme se, ale v této galerii ještě nejou žádné obrázky.";
$lang['back'] = "zpět do galerie";

/* ZAKOMENTOVANÁ SLOVENCINA
$lang['prev'] = "predchádzajúca";
$lang['next'] = "ďalšia";
$lang['omluva'] = "Ospravedlňujeme sa, ale v tejto galérií ešte nie sú žiadne obrázky.";
$lang['back'] = "späť do galérie";
*/

// Configuration variables ------------

$pics_per_row = 4;    // Number of thumbnails per row
$rows_per_page = 4;   // Number of rows per page (set to 0 for all thumbnails on a single page)

$nav_thumbs_top = true;      // Set to true to display top nav bar on thumbnails pages
$nav_thumbs_bot = true;      // Same for the bottom nav bar

$nav_detail_top = true;      // Set to true to display top nav bar on details pages
$nav_detail_bot = true;      // Same for the bottom nav bar

// ------------------------------------

if (empty($g_pic))  $g_pic  = $GLOBALS["HTTP_GET_VARS"]["g_pic"];
if (empty($g_view)) $g_view = $GLOBALS["HTTP_GET_VARS"]["g_view"];
if (empty($g_page)) $g_page = $GLOBALS["HTTP_GET_VARS"]["g_page"];

$id = $GLOBALS["HTTP_GET_VARS"]["id"];

$path = empty($HTTP_SERVER_VARS["PATH_INFO"]) ? $HTTP_SERVER_VARS["PHP_SELF"] : $HTTP_SERVER_VARS["PATH_INFO"];
@$dirhandle = opendir( "$directory/thumbs" );
$pic_count = 0;

while( $file = readdir( $dirhandle ) )
{
   if (eregi("(gif|jpg|jpeg)$",$file))
   {
      $pic_list[$pic_count++] = $file;
   }
}

if ($pic_count==0) return "<p>" . $lang['omluva'] . "</p>";

$output = '';
$page_for_pic = 0;
$pics_per_page = $pics_per_row * $rows_per_page;

if ( ($g_pic >= $pic_count) || (empty($g_pic)) )
   $g_pic = 0;
else
   if ($pics_per_page!=0) $page_for_pic = (int)($g_pic / $pics_per_page);

if ($g_view=="detail")
{
   // Display single picture block
   $next = $g_pic + $pic_count + 1; $next %= $pic_count;
   $prev = $g_pic + $pic_count - 1; $prev %= $pic_count;

   $output .= '<div id="EPG_detail_container">';

   if ($nav_detail_top)
   {
      $output .=    '<div id="EPG_text_container1">';
      $output .=       '<div id="EPG_text_sub_container1">';
      $output .=          '<a id="EPG_prev1" href="'.$path.'?g_pic='.$prev.'&g_view=detail"><img src=./assets/images/EPG_prev.gif />' . $lang['prev'] . '</a>';
      $output .=          '<a id="EPG_next1" href="'.$path.'?g_pic='.$next.'&g_view=detail">' . $lang['next'] . '<img src=./assets/images/EPG_next.gif /></a>';
      $output .=          '<a id="EPG_back1" href="'.$path.'?g_view=thumbs&g_page='.$page_for_pic.'">[' . $lang['back'] . ']</a>';
      $output .=       '</div>';
      $output .=    '</div>';
   }

   $output .=    '<div id="EPG_image_container">';
   $output .=       '<img id="EPG_image" src="'.$directory.'/large/'.$pic_list[$g_pic].'"><br />';
   $output .=    '</div>';

   if ($nav_detail_bot)
   {
      $output .=    '<div id="EPG_text_container2">';
      $output .=       '<div id="EPG_text_sub_container2">';
      $output .=          '<a id="EPG_prev2" href="'.$path.'?g_pic='.$prev.'&g_view=detail"><img src=./assets/images/EPG_prev.gif />' . $lang['prev'] . '</a>';
      $output .=          '<a id="EPG_next2" href="'.$path.'?g_pic='.$next.'&g_view=detail">' . $lang['next'] . '<img src=./assets/images/EPG_next.gif /></a>';
      $output .=          '<a id="EPG_back2" href="'.$path.'?g_view=thumbs&g_page='.$page_for_pic.'">[' . $lang['back'] . ']</a>';
      $output .=       '</div>';
      $output .=    '</div>';
   }

   $output .= '</div>';
}
else
{
   // Display thumbnail block
   if ($rows_per_page!=0)
      $pages = ceil($pic_count/$pics_per_page);
   else
      $pages = 1;

   $nextpage = $pages + $g_page + 1 ; $nextpage %= $pages;
   $prevpage = $pages + $g_page - 1 ; $prevpage %= $pages;

   $output .= '<div id="EPG_thumbs_container">';

   if ( ($rows_per_page!=0) && ($pic_count>$pics_per_page) && ($nav_thumbs_top) )
   {
      $output .= '<div id="EPG_prev-next_1">';
      $output .=    '<a id="EPG_prev1" href="'.$path.'?g_page='.$prevpage.'&g_view=thumbs"><img src=./assets/images/EPG_prev.gif />' . $lang['prev'] . '</a>';
      $output .=    '<a id="EPG_next1" href="'.$path.'?g_page='.$nextpage.'&g_view=thumbs">' . $lang['next'] . '<img src=./assets/images/EPG_next.gif /></a>';
      $output .=    '<div id="EPG_pages_container1">';
      $output .=       '<div id="EPG_pages_sub_container1">';

      for ($p=0;$p<$pages;$p++)
         $output .=       '<a class="'.($p!=$g_page?"EPG_pages":"EPG_pages_current").'" href="'.$path.'?g_page='.$p.'&g_view=thumbs">'.($p+1).'</a>&nbsp';

      $output .=       '</div>';
      $output .=    '</div>';
      $output .= '</div>';
   }

   $pstart = $g_page*$pics_per_page;
   $pend   = $pstart + $pics_per_page;
   if ($pend>$pic_count) $pend=$pic_count;

   $output .= '<table cellpadding="0" cellspacing="0" id="EPG_thumbs_table"><tr>';

   for ($i=$pstart;$i<$pend;$i++)
   {
      if ( ($i%$pics_per_row==0) && ($i!=0) ) $output .= '</tr><tr>';

      $output .= '<td style="width:'.(100/$pics_per_row).'%;">';
      $output .= '<a align="center" href="'.$path.'?g_pic='.$i.'&g_view=detail"><img src="./'.$directory.'/thumbs/'.$pic_list[$i].'"/></a>';
      $output .= '</td>';
   }

   $output .= '</tr></table>';

   if ( ($rows_per_page!=0) && ($pic_count>$pics_per_page) && ($nav_thumbs_bot) )
   {
      $output .= '<div id="EPG_prev-next_2">';
      $output .=    '<a id="EPG_prev2" href="'.$path.'?g_page='.$prevpage.'&g_view=thumbs"><img src=./assets/images/EPG_prev.gif />' . $lang['prev'] . '</a>';
      $output .=    '<a id="EPG_next2" href="'.$path.'?g_page='.$nextpage.'&g_view=thumbs">' . $lang['next'] . '<img src=./assets/images/EPG_next.gif /></a>';
      $output .=    '<div id="EPG_pages_container2">';
      $output .=       '<div id="EPG_pages_sub_container2">';

      for ($p=0;$p<$pages;$p++)
         $output .=       '<a class="'.($p!=$g_page?"EPG_pages":"EPG_pages_current").'" href="'.$path.'?g_page='.$p.'&g_view=thumbs">'.($p+1).'</a>&nbsp';

      $output .=       '</div>';
      $output .=    '</div>';
      $output .= '</div>';
   }

   $output .= '</div>';
}

return $output;
  • The Neverhood - Československý web o Neverhoodovi
  • P.R.D.I. - nejlepší folkrock široko daleko
  • Yozzefy - hudební gulášek známých písní
Obrázok užívateľa
churchyard
Czech LT
Czech LT
 
Príspevky: 181
Registrovaný: Ned Nov 06, 2005 3:40 pm
Bydlisko: Praha [CZ]

mp3get

Poslaťod churchyard » Uto Júl 03, 2007 2:43 pm

Zlodějský snippet [[mp3get]]
autor churchyard
Získává link na mp3ku z http://gh.ffshrine.org
Volá se takhle: [[mp3get?url=2612/34]]
Sosá to JScript a je vám to k ničemu pokud nepotřebujete dát na web linky na mp3ky z toho webu. Je to pomalé.
Demo: http://neverhood.etomite.sk/neverhood_mp3s.htm (~30 sec. načítání / 39 mp3)
Kód: Vybrať všetko
// OTEVREME SOUBOR
$url = "http://gh.ffshrine.org/song/" . $url;
$handle = fopen($url, "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}

// ZAVREME SOUBOR
fclose($handle);


preg_match('/var data = "(.*?)";/si', $contents, $co);

$escape = preg_replace('/var data = "(.*?)";/si', "$1", $co["0"]);
$nove = decodeescape($escape);


$nove = str_replace('document.getElementById("linkcode").innerHTML = "<a href=\\"" + unescapesome(escape(Address)) + "\\">click here</a>";', "return unescapesome(escape(Address));", $nove);


$nove = str_replace("decode(addr);", 'document.write("<a href=\"" + decode(addr) + "\">download</a>");', $nove);



$jscript .= "<script type=\"text/javascript\">" . "\r";
$jscript .= "<!--" . "\r";
$jscript .= $nove . "\r";
$jscript .= "// -->" . "\r";
$jscript .= "</script>" . "\r";

$output = $jscript;


return $output;
  • The Neverhood - Československý web o Neverhoodovi
  • P.R.D.I. - nejlepší folkrock široko daleko
  • Yozzefy - hudební gulášek známých písní
Obrázok užívateľa
churchyard
Czech LT
Czech LT
 
Príspevky: 181
Registrovaný: Ned Nov 06, 2005 3:40 pm
Bydlisko: Praha [CZ]

TranslateAlias

Poslaťod churchyard » Uto Júl 03, 2007 3:11 pm

[[TranslateAlias]] by churchyard
Hodi se to na multijazicne stranky.
V pripade [[TranslateAlias?tolang=cze]] se urizne prefix svk_.
V pripade [[TranslateAlias?tolang=svk]] se prida prefix svk_.
Priponu za aliasem musite nastavit sami na predposlednim radku.
Demo: http://neverhood.etomite.sk/home.htm > vlajecka pravo nahore.
Kód: Vybrať všetko
if(isset($transalias)){
$tenhle_alias = $transalias;
}
else {
$tenhle_alias = $this->aliases[$etomite->documentIdentifier];
}
if($tolang == "cze") {
$novy_alias = str_replace("svk_", "", $tenhle_alias);
}
elseif($tolang == "svk") {
$novy_alias = "svk_" . $tenhle_alias;
}
else {
$novy_alias = $tenhle_alias;
}
$url = $novy_alias . ".htm";

return $url;
  • The Neverhood - Československý web o Neverhoodovi
  • P.R.D.I. - nejlepší folkrock široko daleko
  • Yozzefy - hudební gulášek známých písní
Obrázok užívateľa
churchyard
Czech LT
Czech LT
 
Príspevky: 181
Registrovaný: Ned Nov 06, 2005 3:40 pm
Bydlisko: Praha [CZ]

UbuntuWiki

Poslaťod churchyard » Uto Júl 03, 2007 3:19 pm

[[UbuntuWiki]]
tenhle snippet vysosá obsah jedné stránky na http://wiki.ubuntu.cz a zobrazí ho.
Je to prasácky a naprosto všechno je tam absolutně, ne relativně. Je dělanej na míru jedný konkrétní stránce. Ale pokud by to někoho bralo, může to zkusit předělat.
Kód: Vybrať všetko
// OTEVREME SOUBOR
$handle = fopen("http://wiki.ubuntu.cz/The_Neverhood?action=raw", "rb");
$content = '';
while (!feof($handle)) {
$content .= fread($handle, 8192);
}

$wikisource = $content;

// ZAVREME SOUBOR
fclose($handle);

$wikisource = iconv("UTF-8", "iso-8859-2", $wikisource);

$wikisource = str_replace('[[ImageLink(neverhood-game.jpg,,height=300)]]','IMGneverhoodIMG',$wikisource);
$wikisource = preg_replace('/\n#([^(\n)]*)/si', '', $wikisource);
$wikisource = preg_replace('/^#([^(\n)]*)/si', '', $wikisource);
$wikisource = preg_replace('/\|\|([^(\n)]*)/si', '', $wikisource);
$wikisource = preg_replace('/`([^`]*)`/si', '<span class="code">$1</span>', $wikisource);
$wikisource = preg_replace('/\'\'\'([^\']*)\'\'\'/si', '<strong>$1</strong>', $wikisource);
$wikisource = preg_replace('/\'\'([^\']*)\'\'/si', '<em>$1</em>', $wikisource);
$wikisource = preg_replace('/\[(http|https|ftp):\/\/([^ ]*)([^\]]*)\]/si', '<a href="$1://$2">$3</a>', $wikisource);
$wikisource = preg_replace('/=== ([^=]*)===/si', '<h5>$1</h5>', $wikisource);
$wikisource = preg_replace('/== ([^=]*)==/si', '<h4>$1</h4>', $wikisource);
$wikisource = preg_replace('/= ([^=]*)=/si', '<h3>$1</h3>', $wikisource);
$wikisource = preg_replace('/\[:([^:]*):\]/si', '<a href="http://wiki.ubuntu.cz/$1">$1</a>', $wikisource);
$wikisource = preg_replace('/\["([^"]*)"\]/si', '<a href="http://wiki.ubuntu.cz/$1">$1</a>', $wikisource);
$wikisource = preg_replace('/\[:([^:]*):([^\]]*)\]/si', '<a href="http://wiki.ubuntu.cz/$1">$2</a>', $wikisource);
$wikisource = preg_replace('/attachment:IconsPage\/([^(\n)]*)/si', '<img src="http://wiki.ubuntu.cz/IconsPage?action=AttachFile&do=get&target=$1', $wikisource);
$wikisource = preg_replace('/attachment:([^(\n)]*)/si', '<img src="http://wiki.ubuntu.cz/The_Neverhood?action=AttachFile&do=get&target=$1', $wikisource);
$wikisource = str_replace(".png", ".png\" />", $wikisource);
$wikisource = str_replace(".jpg", ".jpg\" />", $wikisource);
$wikisource = str_replace(".gif", ".gif\" />", $wikisource);
$wikisource = preg_replace("/{{{(\n)?(\r)?(\n)?/si", '<div class="box"><span class="code">', $wikisource);
$wikisource = preg_replace("/(\n)?(\r)?(\n)?}}}/si", '</span></div>', $wikisource);
$wikisource = str_replace(" </h", "</h", $wikisource);
$wikisource = str_replace("\\\\", "\\\\\\\\", $wikisource);
$wikisource = preg_replace('/\n ?/si', "\n", $wikisource);
$wikisource = preg_replace('/\n(\r)?\n(\r)?/si', "</p>\n<p>", $wikisource);
$wikisource = preg_replace('/<p><h([3-5])>([^<]*)<\/h([3-5])>/si', '<h$1>$2</h$1><p>', $wikisource);
$wikisource = str_replace("</p>\n<p></p>\n<p>", "", $wikisource);
$wikisource = preg_replace("/<p>(\n)?(\r)?<\/p>/si", "\n\r", $wikisource);
$wikisource = preg_replace('/^(.*) Tento/si', '<h3>Úvod</h3><p><img src="http://wiki.ubuntu.cz/IconsPage?action=AttachFile&do=get&target=wine.png" /> Tento', $wikisource);
$wikisource = preg_replace('/<h3>Odkazy(.*)/si', '', $wikisource);
$wikisource = nl2br($wikisource);
$wikisource = preg_replace("/<br \/>(\n)?(\r)?<\/p>/si", "</p>", $wikisource);
$wikisource = preg_replace("/<br \/>(\n)?(\r)?<p>/si", "<p>", $wikisource);
$wikisource = preg_replace("/<\/p>(\n)?(\r)?<br \/>/si", "</p>", $wikisource);
$wikisource = preg_replace("/<p>(\n)?(\r)?<br \/>/si", "<p>", $wikisource);
$wikisource = preg_replace("/<\/h3>(\n)?(\r)?<br \/>/si", "</h3>", $wikisource);
$wikisource = preg_replace("/<\/h4>(\n)?(\r)?<br \/>/si", "</h4>", $wikisource);
$wikisource = preg_replace("/<\/h5>(\n)?(\r)?<br \/>/si", "</h5>", $wikisource);
$wikisource = preg_replace("/<br \/>(\n)?(\r)?<h3>/si", "<h3>", $wikisource);
$wikisource = preg_replace("/<br \/>(\n)?(\r)?<h4>/si", "<h4>", $wikisource);
$wikisource = preg_replace("/<br \/>(\n)?(\r)?<h5>/si", "<h5>", $wikisource);
$wikisource = str_replace('IMGneverhoodIMG','<a href="imgs/wineshot.jpg"><img alt="Screenshot" src="imgs/wineshot.png" /></a>',$wikisource);
$wikisource = str_replace('http://wiki.ubuntu.cz/Terminál','http://wiki.ubuntu.cz/Termin%C3%A1l',$wikisource);


return $wikisource;
Zároveň se obracím s prosbou na zkušenější php programátory: potřebuju funkci, která předělá v konkrétním URL íľžáéáťľťžň znaky na %C3%A1 <- takovéhle. Ale podle UTF8ky, když stránky mají jineé kódování. Viz předposlední řádek kódu.
Kód: Vybrať všetko
str_replace('http://wiki.ubuntu.cz/Terminál','http://wiki.ubuntu.cz/Termin%C3%A1l',$wikisource);
  • The Neverhood - Československý web o Neverhoodovi
  • P.R.D.I. - nejlepší folkrock široko daleko
  • Yozzefy - hudební gulášek známých písní
Obrázok užívateľa
churchyard
Czech LT
Czech LT
 
Príspevky: 181
Registrovaný: Ned Nov 06, 2005 3:40 pm
Bydlisko: Praha [CZ]

Events

Poslaťod churchyard » Uto Júl 03, 2007 3:37 pm

Teď přijdou 3 modifikace 1 snippetu:
Jelikož dělám stránky i hudebním skupinám, tak:
Akce skupiny co budou následovat [[Events]]
Akce skupiny co už byli [[OldEvents]]
Akce skupiny co je nejblíž před náma [[OneEvent]]
Postup: udělejte si složku někde v repository, já ji mám nazvanou Events a její ID je 56 (vaše ID musíte změnit ve zdrojáku, nebo ho měnit pomocí $resourceparent).
Pak přidávejte dokumenty do té složky a řiďte se tímto:
Alias je YYYYMMDD = 20070703 pro dnešek
čas musíte napsat do těla dokumentu. tělo dokumentu bych nedělil na odstavce, vypadá to blbě.
Návštěvníci uvidí jen Dlouhý název dokumentu.
Demo: http://www.yozzefy.cz vpravo nahoře a http://www.yozzefy.cz/akce.htm a http://www.yozzefy.cz/archiv.htm
Kód: Vybrať všetko
// EVENTS

$den=array('Ne', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So'); // by churchyard

/* you can use the snippet as follows:
[[Events?resourceparent=4&maxEventNumbers=6&maxPeriod=6]]
To set a default setting here you can change the last number after the variable name in the following three lines, e.g.
$resourceparent = isset($resourceparent) ? $resourceparent : 8; means $resourceparent=8 if not set in the snippet call.
*/
$resourceparent = isset($resourceparent) ? $resourceparent : 56;
$maxEventNumbers = isset($maxEventNumbers ) ? $maxEventNumbers : 1000;
$maxPeriod = isset($maxPeriod ) ? $maxPeriod :1000;
$showEventInformation = isset($showEventInformation ) ? $showEventInformation : true;
$fullEventDate = isset($fullEventDate ) ? $fullEventDate : 'd.m.Y';
$quickEventDate = isset($quickEventDate ) ? $quickEventDate : 'd.m.';
$monthNames = array('Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');

/* output generation */
$output = '';
$resource = $etomite->getActiveChildren($resourceparent, 'alias', 'ASC', $fields='id, longtitle, alias, description, content');

$displayedEvents = 0;
$numberEvents = count($resource);
$lastMonth = -1;
$currentDate = mktime(0,0,0);
$endDate = $currentDate + $maxPeriod * 30 * 24 * 60 * 60;

for ($i = 0; $i < $numberEvents && $displayedEvents < $maxEventNumbers; ++$i) {
   $alias = $resource[$i]['alias'];
   $eventtitle = $resource[$i]['longtitle'];
   
   if (strlen($alias) > 0 && strlen($eventtitle) > 0 && preg_match('/^\d{8,8}/',$alias, $dateText)) {
      $dateYear = substr($dateText[0], 0, 4);
      $dateMonth = substr($dateText[0], 4, 2);
      $dateDay = substr($dateText[0], 6, 2);
      $eventDate = mktime(0, 0, 0, $dateMonth, $dateDay, $dateYear);
      if ($eventDate < $currentDate || $eventDate > $endDate) {
         continue;
      }
      $dateArray = getdate($eventDate);
      $curMonth = $dateArray['mon'];
      if ($curMonth != $lastMonth) {
         if ($lastMonth != -1) {
            $output .= '</li></ul>';
         }
         $output .= '<li class="eventmonth"><strong>'.$monthNames[$curMonth-1].'</strong><ul>';
      }
      $pageid = $resource[$i]['id'];
      $eventdescription = $resource[$i]['description'] == '' ? "$eventtitle - ".date($fullEventDate,$eventDate) : $resource[$i]['description'];
      $eventInformation = $resource[$i]['content'];
      $href = "<strong>".date($quickEventDate ,$eventDate)." ".$den[date("w",$eventDate)]."</strong> - ".$eventtitle;
      $output .= "<li class=\"eventitem\">$href".($showEventInformation ? "<br/><span class=\"event-information\">$eventInformation</span>" : '')."</li>";
      ++$displayedEvents;
      $lastMonth  = $curMonth;
   }
}

if (strlen($output) == 0) {
   $output .= "Žádné akce nenalezeny.";
} else {
   $output = '<ul>'.$output.'</ul></li></ul>';
}

return $output;
Kód: Vybrať všetko
// OLD EVENTS

$den=array('Ne', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So'); // by churchyard

/* you can use the snippet as follows:
[[Events?resourceparent=4&maxEventNumbers=6&maxPeriod=6]]
To set a default setting here you can change the last number after the variable name in the following three lines, e.g.
$resourceparent = isset($resourceparent) ? $resourceparent : 8; means $resourceparent=8 if not set in the snippet call.
*/
$resourceparent = isset($resourceparent) ? $resourceparent : 56;
$maxEventNumbers = isset($maxEventNumbers ) ? $maxEventNumbers : 1000;
$maxPeriod = isset($maxPeriod ) ? $maxPeriod :1000;
$showEventInformation = isset($showEventInformation ) ? $showEventInformation : true;
$fullEventDate = isset($fullEventDate ) ? $fullEventDate : 'd.m.Y';
$quickEventDate = isset($quickEventDate ) ? $quickEventDate : 'd.m.';
$monthNames = array('Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');

/* output generation */
$output = '';
$resource = $etomite->getActiveChildren($resourceparent, 'alias', 'DESC', $fields='id, longtitle, alias, description, content');

$displayedEvents = 0;
$numberEvents = count($resource);
$lastMonth = -1;
$currentDate = mktime(0,0,0);
$endDate = $currentDate + $maxPeriod * 30 * 24 * 60 * 60;

for ($i = 0; $i < $numberEvents && $displayedEvents < $maxEventNumbers; ++$i) {
   $alias = $resource[$i]['alias'];
   $eventtitle = $resource[$i]['longtitle'];
   
   if (strlen($alias) > 0 && strlen($eventtitle) > 0 && preg_match('/^\d{8,8}/',$alias, $dateText)) {
      $dateYear = substr($dateText[0], 0, 4);
      $dateMonth = substr($dateText[0], 4, 2);
      $dateDay = substr($dateText[0], 6, 2);
      $eventDate = mktime(0, 0, 0, $dateMonth, $dateDay, $dateYear);
/*      if ($eventDate < $currentDate || $eventDate > $endDate) { */
      if ($eventDate > $currentDate || $eventDate > $endDate) {
         continue;
      }
      $dateArray = getdate($eventDate);
      $curMonth = $dateArray['mon'];
      $year = date("Y",$eventDate);
      if ($curMonth != $lastMonth) {
         if ($lastMonth != -1) {
            $output .= '</li></ul>';
         }
         $output .= '<li class="eventmonth"><strong>'.$monthNames[$curMonth-1].' '.$year .'</strong><ul>';
      }
      $pageid = $resource[$i]['id'];
      $eventdescription = $resource[$i]['description'] == '' ? "$eventtitle - ".date($fullEventDate,$eventDate) : $resource[$i]['description'];
      $eventInformation = $resource[$i]['content'];
      $href = "<strong>".date($quickEventDate ,$eventDate)." ".$den[date("w",$eventDate)]."</strong> - ".$eventtitle;
      $output .= "<li class=\"eventitem\">$href".($showEventInformation ? "<br/><span class=\"event-information\">$eventInformation</span>" : '')."</li>";
      ++$displayedEvents;
      $lastMonth  = $curMonth;
   }
}

if (strlen($output) == 0) {
   $output .= "Žádné akce nenalezeny.";
} else {
   $output = '<ul>'.$output.'</ul></li></ul>';
}

return $output;
Kód: Vybrať všetko
// ONE EVENT

$den=array('Neděle', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota'); // by churchyard

/* you can use the snippet as follows:
[[Events?resourceparent=4&maxEventNumbers=6&maxPeriod=6]]
To set a default setting here you can change the last number after the variable name in the following three lines, e.g.
$resourceparent = isset($resourceparent) ? $resourceparent : 8; means $resourceparent=8 if not set in the snippet call.
*/
$resourceparent = isset($resourceparent) ? $resourceparent : 56;
$maxEventNumbers = isset($maxEventNumbers ) ? $maxEventNumbers : 1;
$maxPeriod = isset($maxPeriod ) ? $maxPeriod :100;
$showEventInformation = isset($showEventInformation ) ? $showEventInformation : true;
$fullEventDate = isset($fullEventDate ) ? $fullEventDate : 'd.m.Y';
$quickEventDate = isset($quickEventDate ) ? $quickEventDate : 'd.m.';
$monthNames = array('Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');

/* output generation */
$output = '';
$resource = $etomite->getActiveChildren($resourceparent, 'alias', 'ASC', $fields='id, longtitle, alias, description, content');

$displayedEvents = 0;
$numberEvents = count($resource);
$lastMonth = -1;
$currentDate = mktime(0,0,0);
$endDate = $currentDate + $maxPeriod * 30 * 24 * 60 * 60;

for ($i = 0; $i < $numberEvents && $displayedEvents < $maxEventNumbers; ++$i) {
   $alias = $resource[$i]['alias'];
   $eventtitle = $resource[$i]['longtitle'];
   
   if (strlen($alias) > 0 && strlen($eventtitle) > 0 && preg_match('/^\d{8,8}/',$alias, $dateText)) {
      $dateYear = substr($dateText[0], 0, 4);
      $dateMonth = substr($dateText[0], 4, 2);
      $dateDay = substr($dateText[0], 6, 2);
      $eventDate = mktime(0, 0, 0, $dateMonth, $dateDay, $dateYear);
      if ($eventDate < $currentDate || $eventDate > $endDate) {
         continue;
      }
      $dateArray = getdate($eventDate);
      $curMonth = $dateArray['mon'];
      if ($curMonth != $lastMonth) {
         if ($lastMonth != -1) {
            $output .= '';
         }
         $output .= '<div class="featurebox">';
      }
      $pageid = $resource[$i]['id'];
      $eventdescription = $resource[$i]['description'] == '' ? "$eventtitle - ".date($fullEventDate,$eventDate) : $resource[$i]['description'];
      $eventInformation = $resource[$i]['content'];
      $href = "";
      $output .= "<h3>".$den[date("w",$eventDate)].", ".date($quickEventDate ,$eventDate)."</h3><p><strong>".$eventtitle."</strong> - ".$eventInformation."</p>";
      ++$displayedEvents;
      $lastMonth  = $curMonth;
   }
}

if (strlen($output) == 0) {
   $output .= "&nbsp;";
} else {
   $output .= "</div>";
}

return $output;
// EDIT: nejak se mi tam dostal kus reklamy :)
Naposledy upravil churchyard dňa Uto Dec 04, 2007 11:28 am, celkovo upravené 1
  • The Neverhood - Československý web o Neverhoodovi
  • P.R.D.I. - nejlepší folkrock široko daleko
  • Yozzefy - hudební gulášek známých písní
Obrázok užívateľa
churchyard
Czech LT
Czech LT
 
Príspevky: 181
Registrovaný: Ned Nov 06, 2005 3:40 pm
Bydlisko: Praha [CZ]

Re: UbuntuWiki

Poslaťod dutch » Uto Júl 03, 2007 7:57 pm

churchyard píše:...
Zároveň se obracím s prosbou na zkušenější php programátory: potřebuju funkci, která předělá v konkrétním URL íľžáéáťľťžň znaky na %C3%A1 <- takovéhle. Ale podle UTF8ky, když stránky mají jineé kódování. Viz předposlední řádek kódu.
Kód: Vybrať všetko
str_replace('http://wiki.ubuntu.cz/Terminál','http://wiki.ubuntu.cz/Termin%C3%A1l',$wikisource);

no tak na tohle staci neco z tohohle:
rawurldecode
rawurlencode
urldecode
urlencode

na znakovy sade stranky to v podstate nezalezi, protoze url se prepisuje ve smyslu RFC1738, coz oznacuje nealfanumericky znaky jako % plus cislo sesnactkovy soustavy poradi znaku, pricemz -, _ a . se nemeni, a mezera se podle pouzity funkce prepisuje bud na + nebo na %20...

ale je v podstate na tobe jestli budes dodrzovat tuhle normu, protoze snad uz kazdej prohlizec umi s pracovat i s neprepsanejma url, zkus treba udelat odkaz, kde v ceste budou mezery nebo diakritika, prohlizec to proste prelouska a zobrazi... jde jenom o cistotu kodu a kulturu programovani, jedinej problem muze bejt v kodovani zdrojaku, protoze pokud budes mit diakritiku v cemkoli jinym nez utf-8 [unicode], tak muze nastat problem, ze se ta url prepise vlastne na neco jineho
Eto v1 - konečně ;) | Když se dva perou, třetí tam hodí granát...
Obrázok užívateľa
dutch
PHP Support
PHP Support
 
Príspevky: 122
Registrovaný: Sob Dec 17, 2005 10:40 pm
Bydlisko: Mladá Boleslav

Re: Kopa snippetou

Poslaťod churchyard » Str Júl 04, 2007 12:22 am

Problem je v tom, ze tom dlouhe á se prepise na %XY ale aby to fungovalo na UbunutWiki, musí se přepsat na %XY%YZ - utf8 á=dva znaky
  • The Neverhood - Československý web o Neverhoodovi
  • P.R.D.I. - nejlepší folkrock široko daleko
  • Yozzefy - hudební gulášek známých písní
Obrázok užívateľa
churchyard
Czech LT
Czech LT
 
Príspevky: 181
Registrovaný: Ned Nov 06, 2005 3:40 pm
Bydlisko: Praha [CZ]

Re: Kopa snippetou

Poslaťod dutch » Str Júl 04, 2007 8:58 pm

jajajaj kua nojo, toho jsem si nejak nevsiml, omlouvam se...
potom asi nezbyde nic jinyho, nez tu funkci 'vysapnout' ze zdrojaku toho UbntWiki...
Eto v1 - konečně ;) | Když se dva perou, třetí tam hodí granát...
Obrázok užívateľa
dutch
PHP Support
PHP Support
 
Príspevky: 122
Registrovaný: Sob Dec 17, 2005 10:40 pm
Bydlisko: Mladá Boleslav

Re: Kopa snippetou

Poslaťod churchyard » Uto Dec 04, 2007 11:13 am

gabo píše:nazdar potreboval by som helpnut ohladne easy galery, co mas na neverhodovi, ja som to urobil presne tak ako je v popise a vecne mi to vypisuje chybu
Pošli link... jakou chybu?
  • The Neverhood - Československý web o Neverhoodovi
  • P.R.D.I. - nejlepší folkrock široko daleko
  • Yozzefy - hudební gulášek známých písní
Obrázok užívateľa
churchyard
Czech LT
Czech LT
 
Príspevky: 181
Registrovaný: Ned Nov 06, 2005 3:40 pm
Bydlisko: Praha [CZ]


Späť na Etomite snippety

Kto je on-line

Užívatelia prezerajúci fórum: Žiadny registrovaný užívateľ nie je prítomný a 1 hosť

cron