Archives

Monthly Archives
November, 2007
October, 2007
<%ArchiveIndex(5)%> //set item amount of each category on archive index <%ArchiveIndex(5,10,desc)%> //set page amount, show category description <%ArchiveIndex(5,10,none)%> //set page amount, don't show category description */ // plugin needs to work on Nucleus versions <=2.0 as well if (!function_exists('sql_table')){ function sql_table($name) { return 'nucleus_' . $name; } } class NP_ArchiveIndex extends NucleusPlugin { function getName() { return 'Archive Index'; } function getAuthor() { return 'nakahara21 + yu'; } function getURL() { return 'http://repository.datoka.jp/index.php?itemid=167'; } function getVersion() { return '0.77b'; } function getMinNucleusVersion() { return 200; } function supportsFeature($what) { switch($what){ case 'SqlTablePrefix': return 1; default: return 0; } } // a description to be shown on the installed plugins listing function getDescription() { return "Show all item title on archive list. [Optional] amount: limit the amount of links shown (e.g. if you only want to show 5 links on each list by category index). page amount: the amount of links in a page. show_catdesc: show category description. 'desc' or 'none'. Usage: <%ArchiveIndex%>, <%ArchiveIndex(5)%>, <%ArchiveIndex(5,10)%>, <%ArchiveIndex(5,10,desc)%>"; } function install() { if(getNucleusVersion() < 220) { $this->createOption('itemOrder','Order of title index. "time,DESC" or "time,ASC" or "title,DESC" or "title,ASC"','text','time,DESC'); $this->createOption('itemOrder2','Order of title(category selected). "time,DESC" or "time,ASC" or "title,DESC" or "title,ASC"','text','time,DESC'); } else { $this->createOption('itemOrder','Order of title index','select','time,DESC', 'title,DESC|title,DESC|title,ASC|title,ASC|time,DESC|time,DESC|time,ASC|time,ASC'); $this->createOption('itemOrder2','Order of title(category selected)','select','time,DESC', 'title,DESC|title,DESC|title,ASC|title,ASC|time,DESC|time,DESC|time,ASC|time,ASC'); } $this->createOption('catDesc','Show category description.','yesno','yes'); $this->createOption('idateFormat','Date format for item list','text','M d, Y'); $this->createOption('tempHead','Template: Header','text','

#icatName#

'); $this->createOption('tempHeadDesc','Template: Header(description)','text','
#icatDesc#
'); $this->createOption('tempListBegin','Template: List (begin)','text','
    '); $this->createOption('tempListElement','Template: List Element','text','
    #idet#

    '); $this->createOption('tempListClose','Template: List (close)','text','
'); $this->createOption('flg_pluglink','Show plugin link (which works as version checker when logged as admin).','yesno','yes'); } function unInstall() { //nothing to do } function doSkinVar($skinType, $amount, $pamount=10, $show_catdesc='') { global $manager, $member, $blog, $CONF, $catid, $itemid; if (!is_numeric($amount)) $amount = 5; if (!is_numeric($pamount)) $pamount = 10; if ($show_catdesc == '') { if ($this->getOption('catDesc') == 'yes') $show_catdesc = 'desc'; else $show_catdesc = 'none'; } if ($blog) { $b =& $blog; } else { $b =& $manager->getBlog($CONF['DefaultBlog']); } $blogid = $b->getID(); if ($catid) { $this->linkparams = array('catid' => $catid); } //get value from request $page = intRequestVar('ap'); if ($catid) { $item_order = requestVar('ao'); //check value (also used to make flip link) list($itarget, $iorder) = @split(' ',$item_order); if(!($itarget=='time' or $itarget=='title' or $iorder =='desc' or $iorder =='asc')) { $item_order = $this->getOption('itemOrder2'); list($itarget, $iorder) = @split(',',$item_order); } } else { $item_order = $this->getOption('itemOrder'); list($itarget, $iorder) = @split(',',$item_order); } $iorder = strtolower($iorder); $now = time(); $idateformat = $this->getOption('idateFormat'); $archivedate = date('Y-m'); //get item data $query = 'SELECT inumber, ititle, icat, UNIX_TIMESTAMP(itime) as itime, iauthor FROM '.sql_table('item') . ' WHERE iblog=' . $blogid . ' and UNIX_TIMESTAMP(itime)<=' . $now // don't show future items! . ' and idraft=0'; // don't show draft items if ($catid) { $query .= ' and icat=' . intval($catid); //item count in the category $resnum = sql_query($query); $itemnum = mysql_num_rows($resnum); mysql_free_result($resnum); $pagemax = ceil($itemnum / $pamount); } if ($itarget == 'title') $query .= ' ORDER BY ititle'; else $query .= ' ORDER BY itime'; if ($iorder == 'asc') $query .= ' ASC'; else $query .= ' DESC'; if ($catid) { if ($page < 1) $page = 1; $poffset = ($page-1) * $pamount; $query .= " LIMIT $poffset,$pamount"; } $res = sql_query($query); //set data by category $list_cat = array(); $list_item = array(); while ($current = mysql_fetch_object($res)) { if (!$catid and count($list_cat[$current->icat]) > $amount) continue; //check the amount $inumber = $current->inumber; //itemid $idetail = date($idateformat, $current->itime); //itemdate $list_cat[$current->icat][] = $inumber; $list_item[$inumber]['ititle'] = htmlspecialchars(strip_tags($current->ititle)); $list_item[$inumber]['itemlink'] = createItemLink($inumber,$this->linkparams); $list_item[$inumber]['idetail'] = $idetail; } mysql_free_result($res); //show list by category $arr_out = array(); foreach ($list_cat as $icat => $arr_icat) { // buffer category name $icatName = $b->getCategoryName($icat); $icatDesc = $b->getCategoryDesc($icat); if ($show_catdesc == 'desc') $icatDescTitle = ''; // use for title prop. on header link else $icatDescTitle = $b->getCategoryDesc($icat); if (!$catid) $extra = array('catid' => $icat); else $extra = array(); $arclist_link = createArchiveListLink($blogid, $extra); $temp_head = $this->getOption('tempHead'); $temp_head = preg_replace('/#arclist_link#/',$arclist_link, $temp_head); $temp_head = preg_replace('/#icatName#/', $icatName, $temp_head); $temp_head = preg_replace('/#icatDesc#/', $icatDescTitle,$temp_head); $arr_out[$icatName] = $temp_head."\n"; if ($show_catdesc == 'desc') $temp_head_desc = $this->getOption('tempHeadDesc'); $temp_head_desc = preg_replace('/#icatDesc#/', $icatDesc, $temp_head_desc); $arr_out[$icatName] .= $temp_head_desc."\n"; $icnt = 0; $arr_title = array(); foreach ($arr_icat as $inumber) { //buffer item title $ititle = $list_item[$inumber]['ititle']; if (empty($ititle)) $ititle = '(no title)'; $itemlink = $list_item[$inumber]['itemlink']; $idetail = $list_item[$inumber]['idetail']; if ($icnt % 2 == 1) $bg = " class='stripe'"; else $bg = ''; $temp_list_el = $this->getOption('tempListElement'); $temp_list_el = preg_replace('/#bg#/', $bg, $temp_list_el); $temp_list_el = preg_replace('/#ilnk#/', $itemlink, $temp_list_el); $temp_list_el = preg_replace('/#itit#/', $ititle, $temp_list_el); $temp_list_el = preg_replace('/#idet#/', $idetail, $temp_list_el); $arr_title[] = $temp_list_el."\n"; $icnt++; if (!$catid and $icnt >= $amount) { //'more' link $extra = array('catid' => $icat); $arclist_link = createArchiveListLink($blogid, $extra); $arr_title[] = "
  • [ More... ]
  • \n"; break; } } if ($catid) { //make 'order switch' $itarget_flip = ($itarget=='title') ? 'time' : 'title'; //mode change $iorder_flip = ($iorder =='desc') ? 'asc' : 'desc'; //order change $itarget_flip_order = ($itarget_flip =='title') ? 'asc' : 'desc'; //ini-order on mode change if ($itarget == 'title') { $iorder_str = ($iorder == 'desc') ? 'Z-A' : 'A-Z'; $iorder_flip_str = ($iorder == 'desc') ? 'A-Z' : 'Z-A'; } else { //time $iorder_str = ($iorder == 'desc') ? 'New' : 'Old'; $iorder_flip_str = ($iorder == 'desc') ? 'Old' : 'New'; } $orderURL = serverVar('REQUEST_URI'); $orderURL = preg_replace('/[?&]ap=[0-9]*/','',$orderURL); //delete to add 'ap' param to last $orderURL = preg_replace('/[?&]ao=[^&0-9]*/','',$orderURL); if (strpos($orderURL,'?')===false) $orderURL .= "?ao="; else $orderURL .= "&ao="; $orderURL1 = $orderURL . "$itarget_flip+$itarget_flip_order&ap=".$page; $orderURL2 = $orderURL . "$itarget+$iorder_flip&ap=".$page; $pagenavi = "Sort: $itarget/$itarget_flip, "; $pagenavi.= "$iorder_str/$iorder_flip_str"; //make 'page link' $pagenavi.= "   Page: "; for ($i=1; $i<=$pagemax; $i++) { if ($i==$page) $pagenavi.= "$i "; else { $pageURL = serverVar('REQUEST_URI'); $pageURL = preg_replace('/([?&]ap=)[0-9]*/','',$pageURL); if (strpos($pageURL,'?')===false) $pageURL .= "?ap=$i"; else $pageURL .= "&ap=$i"; $pagenavi.= "[$i] "; } } //and make 'all category link' $arclist_link = createArchiveListLink($blogid); $arr_title[] = "
  • $pagenavi [ All Category ]
  • \n"; } $arr_out[$icatName] .= $this->getOption('tempListBegin')."\n" . join('',$arr_title) . $this->getOption('tempListClose')."\n"; } //end of foreach //sort by category ksort($arr_out); foreach ($arr_out as $value) { //flush the buffer echo $value; } //plugin link if ($this->getOption('flg_pluglink') == 'yes') { $pluglink_url = $this->getURL(); $str_pversion = ''; //version check if ($this->canEdit()) { $chkver = $this->getLatestVersion($pluglink_url); if ($chkver > $this->getVersion()) { $str_pversion = " [Ver $chkver available]"; } } $ptitle = 'This is '. $this->getName().'('.$this->getVersion() .') » Go to distribution site'; echo ""; echo "» Get \"".$this->getName()."\"$str_pversion"; } } //end of function doSkinVar // helper function function canEdit() { global $member, $manager; if (!$member->isLoggedIn()) return 0; return $member->isAdmin(); } function getLatestVersion($url) { $name = $this->getShortName(); if ($_COOKIE[$name]) return 0; $fp = @fopen ($url, "r"); if ($fp){ $ref_str = fread($fp, 16384); if (eregi("(.*)", $ref_str, $out)) { setcookie($name,1,null,'/'); // set session cookie return $out[1]; } } return 0; } } //end of class ?> <%ArchiveIndex(5)%> //set item amount of each category on archive index <%ArchiveIndex(5,10,desc)%> //set page amount, show category description <%ArchiveIndex(5,10,none)%> //set page amount, don't show category description */ // plugin needs to work on Nucleus versions <=2.0 as well if (!function_exists('sql_table')){ function sql_table($name) { return 'nucleus_' . $name; } } class NP_ArchiveIndex extends NucleusPlugin { function getName() { return 'Archive Index'; } function getAuthor() { return 'nakahara21 + yu'; } function getURL() { return 'http://repository.datoka.jp/index.php?itemid=167'; } function getVersion() { return '0.77b'; } function getMinNucleusVersion() { return 200; } function supportsFeature($what) { switch($what){ case 'SqlTablePrefix': return 1; default: return 0; } } // a description to be shown on the installed plugins listing function getDescription() { return "Show all item title on archive list. [Optional] amount: limit the amount of links shown (e.g. if you only want to show 5 links on each list by category index). page amount: the amount of links in a page. show_catdesc: show category description. 'desc' or 'none'. Usage: <%ArchiveIndex%>, <%ArchiveIndex(5)%>, <%ArchiveIndex(5,10)%>, <%ArchiveIndex(5,10,desc)%>"; } function install() { if(getNucleusVersion() < 220) { $this->createOption('itemOrder','Order of title index. "time,DESC" or "time,ASC" or "title,DESC" or "title,ASC"','text','time,DESC'); $this->createOption('itemOrder2','Order of title(category selected). "time,DESC" or "time,ASC" or "title,DESC" or "title,ASC"','text','time,DESC'); } else { $this->createOption('itemOrder','Order of title index','select','time,DESC', 'title,DESC|title,DESC|title,ASC|title,ASC|time,DESC|time,DESC|time,ASC|time,ASC'); $this->createOption('itemOrder2','Order of title(category selected)','select','time,DESC', 'title,DESC|title,DESC|title,ASC|title,ASC|time,DESC|time,DESC|time,ASC|time,ASC'); } $this->createOption('catDesc','Show category description.','yesno','yes'); $this->createOption('idateFormat','Date format for item list','text','M d, Y'); $this->createOption('tempHead','Template: Header','text','

    #icatName#

    '); $this->createOption('tempHeadDesc','Template: Header(description)','text','
    #icatDesc#
    '); $this->createOption('tempListBegin','Template: List (begin)','text','
      '); $this->createOption('tempListElement','Template: List Element','text','
      #idet#

      '); $this->createOption('tempListClose','Template: List (close)','text','
    '); $this->createOption('flg_pluglink','Show plugin link (which works as version checker when logged as admin).','yesno','yes'); } function unInstall() { //nothing to do } function doSkinVar($skinType, $amount, $pamount=10, $show_catdesc='') { global $manager, $member, $blog, $CONF, $catid, $itemid; if (!is_numeric($amount)) $amount = 5; if (!is_numeric($pamount)) $pamount = 10; if ($show_catdesc == '') { if ($this->getOption('catDesc') == 'yes') $show_catdesc = 'desc'; else $show_catdesc = 'none'; } if ($blog) { $b =& $blog; } else { $b =& $manager->getBlog($CONF['DefaultBlog']); } $blogid = $b->getID(); if ($catid) { $this->linkparams = array('catid' => $catid); } //get value from request $page = intRequestVar('ap'); if ($catid) { $item_order = requestVar('ao'); //check value (also used to make flip link) list($itarget, $iorder) = @split(' ',$item_order); if(!($itarget=='time' or $itarget=='title' or $iorder =='desc' or $iorder =='asc')) { $item_order = $this->getOption('itemOrder2'); list($itarget, $iorder) = @split(',',$item_order); } } else { $item_order = $this->getOption('itemOrder'); list($itarget, $iorder) = @split(',',$item_order); } $iorder = strtolower($iorder); $now = time(); $idateformat = $this->getOption('idateFormat'); $archivedate = date('Y-m'); //get item data $query = 'SELECT inumber, ititle, icat, UNIX_TIMESTAMP(itime) as itime, iauthor FROM '.sql_table('item') . ' WHERE iblog=' . $blogid . ' and UNIX_TIMESTAMP(itime)<=' . $now // don't show future items! . ' and idraft=0'; // don't show draft items if ($catid) { $query .= ' and icat=' . intval($catid); //item count in the category $resnum = sql_query($query); $itemnum = mysql_num_rows($resnum); mysql_free_result($resnum); $pagemax = ceil($itemnum / $pamount); } if ($itarget == 'title') $query .= ' ORDER BY ititle'; else $query .= ' ORDER BY itime'; if ($iorder == 'asc') $query .= ' ASC'; else $query .= ' DESC'; if ($catid) { if ($page < 1) $page = 1; $poffset = ($page-1) * $pamount; $query .= " LIMIT $poffset,$pamount"; } $res = sql_query($query); //set data by category $list_cat = array(); $list_item = array(); while ($current = mysql_fetch_object($res)) { if (!$catid and count($list_cat[$current->icat]) > $amount) continue; //check the amount $inumber = $current->inumber; //itemid $idetail = date($idateformat, $current->itime); //itemdate $list_cat[$current->icat][] = $inumber; $list_item[$inumber]['ititle'] = htmlspecialchars(strip_tags($current->ititle)); $list_item[$inumber]['itemlink'] = createItemLink($inumber,$this->linkparams); $list_item[$inumber]['idetail'] = $idetail; } mysql_free_result($res); //show list by category $arr_out = array(); foreach ($list_cat as $icat => $arr_icat) { // buffer category name $icatName = $b->getCategoryName($icat); $icatDesc = $b->getCategoryDesc($icat); if ($show_catdesc == 'desc') $icatDescTitle = ''; // use for title prop. on header link else $icatDescTitle = $b->getCategoryDesc($icat); if (!$catid) $extra = array('catid' => $icat); else $extra = array(); $arclist_link = createArchiveListLink($blogid, $extra); $temp_head = $this->getOption('tempHead'); $temp_head = preg_replace('/#arclist_link#/',$arclist_link, $temp_head); $temp_head = preg_replace('/#icatName#/', $icatName, $temp_head); $temp_head = preg_replace('/#icatDesc#/', $icatDescTitle,$temp_head); $arr_out[$icatName] = $temp_head."\n"; if ($show_catdesc == 'desc') $temp_head_desc = $this->getOption('tempHeadDesc'); $temp_head_desc = preg_replace('/#icatDesc#/', $icatDesc, $temp_head_desc); $arr_out[$icatName] .= $temp_head_desc."\n"; $icnt = 0; $arr_title = array(); foreach ($arr_icat as $inumber) { //buffer item title $ititle = $list_item[$inumber]['ititle']; if (empty($ititle)) $ititle = '(no title)'; $itemlink = $list_item[$inumber]['itemlink']; $idetail = $list_item[$inumber]['idetail']; if ($icnt % 2 == 1) $bg = " class='stripe'"; else $bg = ''; $temp_list_el = $this->getOption('tempListElement'); $temp_list_el = preg_replace('/#bg#/', $bg, $temp_list_el); $temp_list_el = preg_replace('/#ilnk#/', $itemlink, $temp_list_el); $temp_list_el = preg_replace('/#itit#/', $ititle, $temp_list_el); $temp_list_el = preg_replace('/#idet#/', $idetail, $temp_list_el); $arr_title[] = $temp_list_el."\n"; $icnt++; if (!$catid and $icnt >= $amount) { //'more' link $extra = array('catid' => $icat); $arclist_link = createArchiveListLink($blogid, $extra); $arr_title[] = "
  • [ More... ]
  • \n"; break; } } if ($catid) { //make 'order switch' $itarget_flip = ($itarget=='title') ? 'time' : 'title'; //mode change $iorder_flip = ($iorder =='desc') ? 'asc' : 'desc'; //order change $itarget_flip_order = ($itarget_flip =='title') ? 'asc' : 'desc'; //ini-order on mode change if ($itarget == 'title') { $iorder_str = ($iorder == 'desc') ? 'Z-A' : 'A-Z'; $iorder_flip_str = ($iorder == 'desc') ? 'A-Z' : 'Z-A'; } else { //time $iorder_str = ($iorder == 'desc') ? 'New' : 'Old'; $iorder_flip_str = ($iorder == 'desc') ? 'Old' : 'New'; } $orderURL = serverVar('REQUEST_URI'); $orderURL = preg_replace('/[?&]ap=[0-9]*/','',$orderURL); //delete to add 'ap' param to last $orderURL = preg_replace('/[?&]ao=[^&0-9]*/','',$orderURL); if (strpos($orderURL,'?')===false) $orderURL .= "?ao="; else $orderURL .= "&ao="; $orderURL1 = $orderURL . "$itarget_flip+$itarget_flip_order&ap=".$page; $orderURL2 = $orderURL . "$itarget+$iorder_flip&ap=".$page; $pagenavi = "Sort: $itarget/$itarget_flip, "; $pagenavi.= "$iorder_str/$iorder_flip_str"; //make 'page link' $pagenavi.= "   Page: "; for ($i=1; $i<=$pagemax; $i++) { if ($i==$page) $pagenavi.= "$i "; else { $pageURL = serverVar('REQUEST_URI'); $pageURL = preg_replace('/([?&]ap=)[0-9]*/','',$pageURL); if (strpos($pageURL,'?')===false) $pageURL .= "?ap=$i"; else $pageURL .= "&ap=$i"; $pagenavi.= "[$i] "; } } //and make 'all category link' $arclist_link = createArchiveListLink($blogid); $arr_title[] = "
  • $pagenavi [ All Category ]
  • \n"; } $arr_out[$icatName] .= $this->getOption('tempListBegin')."\n" . join('',$arr_title) . $this->getOption('tempListClose')."\n"; } //end of foreach //sort by category ksort($arr_out); foreach ($arr_out as $value) { //flush the buffer echo $value; } //plugin link if ($this->getOption('flg_pluglink') == 'yes') { $pluglink_url = $this->getURL(); $str_pversion = ''; //version check if ($this->canEdit()) { $chkver = $this->getLatestVersion($pluglink_url); if ($chkver > $this->getVersion()) { $str_pversion = " [Ver $chkver available]"; } } $ptitle = 'This is '. $this->getName().'('.$this->getVersion() .') » Go to distribution site'; echo ""; echo "» Get \"".$this->getName()."\"$str_pversion"; } } //end of function doSkinVar // helper function function canEdit() { global $member, $manager; if (!$member->isLoggedIn()) return 0; return $member->isAdmin(); } function getLatestVersion($url) { $name = $this->getShortName(); if ($_COOKIE[$name]) return 0; $fp = @fopen ($url, "r"); if ($fp){ $ref_str = fread($fp, 16384); if (eregi("(.*)", $ref_str, $out)) { setcookie($name,1,null,'/'); // set session cookie return $out[1]; } } return 0; } } //end of class ?> <%ArchiveIndex(5)%> //set item amount of each category on archive index <%ArchiveIndex(5,10,desc)%> //set page amount, show category description <%ArchiveIndex(5,10,none)%> //set page amount, don't show category description */ // plugin needs to work on Nucleus versions <=2.0 as well if (!function_exists('sql_table')){ function sql_table($name) { return 'nucleus_' . $name; } } class NP_ArchiveIndex extends NucleusPlugin { function getName() { return 'Archive Index'; } function getAuthor() { return 'nakahara21 + yu'; } function getURL() { return 'http://repository.datoka.jp/index.php?itemid=167'; } function getVersion() { return '0.77b'; } function getMinNucleusVersion() { return 200; } function supportsFeature($what) { switch($what){ case 'SqlTablePrefix': return 1; default: return 0; } } // a description to be shown on the installed plugins listing function getDescription() { return "Show all item title on archive list. [Optional] amount: limit the amount of links shown (e.g. if you only want to show 5 links on each list by category index). page amount: the amount of links in a page. show_catdesc: show category description. 'desc' or 'none'. Usage: <%ArchiveIndex%>, <%ArchiveIndex(5)%>, <%ArchiveIndex(5,10)%>, <%ArchiveIndex(5,10,desc)%>"; } function install() { if(getNucleusVersion() < 220) { $this->createOption('itemOrder','Order of title index. "time,DESC" or "time,ASC" or "title,DESC" or "title,ASC"','text','time,DESC'); $this->createOption('itemOrder2','Order of title(category selected). "time,DESC" or "time,ASC" or "title,DESC" or "title,ASC"','text','time,DESC'); } else { $this->createOption('itemOrder','Order of title index','select','time,DESC', 'title,DESC|title,DESC|title,ASC|title,ASC|time,DESC|time,DESC|time,ASC|time,ASC'); $this->createOption('itemOrder2','Order of title(category selected)','select','time,DESC', 'title,DESC|title,DESC|title,ASC|title,ASC|time,DESC|time,DESC|time,ASC|time,ASC'); } $this->createOption('catDesc','Show category description.','yesno','yes'); $this->createOption('idateFormat','Date format for item list','text','M d, Y'); $this->createOption('tempHead','Template: Header','text','

    #icatName#

    '); $this->createOption('tempHeadDesc','Template: Header(description)','text','
    #icatDesc#
    '); $this->createOption('tempListBegin','Template: List (begin)','text','
      '); $this->createOption('tempListElement','Template: List Element','text','
      #idet#

      '); $this->createOption('tempListClose','Template: List (close)','text','
    '); $this->createOption('flg_pluglink','Show plugin link (which works as version checker when logged as admin).','yesno','yes'); } function unInstall() { //nothing to do } function doSkinVar($skinType, $amount, $pamount=10, $show_catdesc='') { global $manager, $member, $blog, $CONF, $catid, $itemid; if (!is_numeric($amount)) $amount = 5; if (!is_numeric($pamount)) $pamount = 10; if ($show_catdesc == '') { if ($this->getOption('catDesc') == 'yes') $show_catdesc = 'desc'; else $show_catdesc = 'none'; } if ($blog) { $b =& $blog; } else { $b =& $manager->getBlog($CONF['DefaultBlog']); } $blogid = $b->getID(); if ($catid) { $this->linkparams = array('catid' => $catid); } //get value from request $page = intRequestVar('ap'); if ($catid) { $item_order = requestVar('ao'); //check value (also used to make flip link) list($itarget, $iorder) = @split(' ',$item_order); if(!($itarget=='time' or $itarget=='title' or $iorder =='desc' or $iorder =='asc')) { $item_order = $this->getOption('itemOrder2'); list($itarget, $iorder) = @split(',',$item_order); } } else { $item_order = $this->getOption('itemOrder'); list($itarget, $iorder) = @split(',',$item_order); } $iorder = strtolower($iorder); $now = time(); $idateformat = $this->getOption('idateFormat'); $archivedate = date('Y-m'); //get item data $query = 'SELECT inumber, ititle, icat, UNIX_TIMESTAMP(itime) as itime, iauthor FROM '.sql_table('item') . ' WHERE iblog=' . $blogid . ' and UNIX_TIMESTAMP(itime)<=' . $now // don't show future items! . ' and idraft=0'; // don't show draft items if ($catid) { $query .= ' and icat=' . intval($catid); //item count in the category $resnum = sql_query($query); $itemnum = mysql_num_rows($resnum); mysql_free_result($resnum); $pagemax = ceil($itemnum / $pamount); } if ($itarget == 'title') $query .= ' ORDER BY ititle'; else $query .= ' ORDER BY itime'; if ($iorder == 'asc') $query .= ' ASC'; else $query .= ' DESC'; if ($catid) { if ($page < 1) $page = 1; $poffset = ($page-1) * $pamount; $query .= " LIMIT $poffset,$pamount"; } $res = sql_query($query); //set data by category $list_cat = array(); $list_item = array(); while ($current = mysql_fetch_object($res)) { if (!$catid and count($list_cat[$current->icat]) > $amount) continue; //check the amount $inumber = $current->inumber; //itemid $idetail = date($idateformat, $current->itime); //itemdate $list_cat[$current->icat][] = $inumber; $list_item[$inumber]['ititle'] = htmlspecialchars(strip_tags($current->ititle)); $list_item[$inumber]['itemlink'] = createItemLink($inumber,$this->linkparams); $list_item[$inumber]['idetail'] = $idetail; } mysql_free_result($res); //show list by category $arr_out = array(); foreach ($list_cat as $icat => $arr_icat) { // buffer category name $icatName = $b->getCategoryName($icat); $icatDesc = $b->getCategoryDesc($icat); if ($show_catdesc == 'desc') $icatDescTitle = ''; // use for title prop. on header link else $icatDescTitle = $b->getCategoryDesc($icat); if (!$catid) $extra = array('catid' => $icat); else $extra = array(); $arclist_link = createArchiveListLink($blogid, $extra); $temp_head = $this->getOption('tempHead'); $temp_head = preg_replace('/#arclist_link#/',$arclist_link, $temp_head); $temp_head = preg_replace('/#icatName#/', $icatName, $temp_head); $temp_head = preg_replace('/#icatDesc#/', $icatDescTitle,$temp_head); $arr_out[$icatName] = $temp_head."\n"; if ($show_catdesc == 'desc') $temp_head_desc = $this->getOption('tempHeadDesc'); $temp_head_desc = preg_replace('/#icatDesc#/', $icatDesc, $temp_head_desc); $arr_out[$icatName] .= $temp_head_desc."\n"; $icnt = 0; $arr_title = array(); foreach ($arr_icat as $inumber) { //buffer item title $ititle = $list_item[$inumber]['ititle']; if (empty($ititle)) $ititle = '(no title)'; $itemlink = $list_item[$inumber]['itemlink']; $idetail = $list_item[$inumber]['idetail']; if ($icnt % 2 == 1) $bg = " class='stripe'"; else $bg = ''; $temp_list_el = $this->getOption('tempListElement'); $temp_list_el = preg_replace('/#bg#/', $bg, $temp_list_el); $temp_list_el = preg_replace('/#ilnk#/', $itemlink, $temp_list_el); $temp_list_el = preg_replace('/#itit#/', $ititle, $temp_list_el); $temp_list_el = preg_replace('/#idet#/', $idetail, $temp_list_el); $arr_title[] = $temp_list_el."\n"; $icnt++; if (!$catid and $icnt >= $amount) { //'more' link $extra = array('catid' => $icat); $arclist_link = createArchiveListLink($blogid, $extra); $arr_title[] = "
  • [ More... ]
  • \n"; break; } } if ($catid) { //make 'order switch' $itarget_flip = ($itarget=='title') ? 'time' : 'title'; //mode change $iorder_flip = ($iorder =='desc') ? 'asc' : 'desc'; //order change $itarget_flip_order = ($itarget_flip =='title') ? 'asc' : 'desc'; //ini-order on mode change if ($itarget == 'title') { $iorder_str = ($iorder == 'desc') ? 'Z-A' : 'A-Z'; $iorder_flip_str = ($iorder == 'desc') ? 'A-Z' : 'Z-A'; } else { //time $iorder_str = ($iorder == 'desc') ? 'New' : 'Old'; $iorder_flip_str = ($iorder == 'desc') ? 'Old' : 'New'; } $orderURL = serverVar('REQUEST_URI'); $orderURL = preg_replace('/[?&]ap=[0-9]*/','',$orderURL); //delete to add 'ap' param to last $orderURL = preg_replace('/[?&]ao=[^&0-9]*/','',$orderURL); if (strpos($orderURL,'?')===false) $orderURL .= "?ao="; else $orderURL .= "&ao="; $orderURL1 = $orderURL . "$itarget_flip+$itarget_flip_order&ap=".$page; $orderURL2 = $orderURL . "$itarget+$iorder_flip&ap=".$page; $pagenavi = "Sort: $itarget/$itarget_flip, "; $pagenavi.= "$iorder_str/$iorder_flip_str"; //make 'page link' $pagenavi.= "   Page: "; for ($i=1; $i<=$pagemax; $i++) { if ($i==$page) $pagenavi.= "$i "; else { $pageURL = serverVar('REQUEST_URI'); $pageURL = preg_replace('/([?&]ap=)[0-9]*/','',$pageURL); if (strpos($pageURL,'?')===false) $pageURL .= "?ap=$i"; else $pageURL .= "&ap=$i"; $pagenavi.= "[$i] "; } } //and make 'all category link' $arclist_link = createArchiveListLink($blogid); $arr_title[] = "
  • $pagenavi [ All Category ]
  • \n"; } $arr_out[$icatName] .= $this->getOption('tempListBegin')."\n" . join('',$arr_title) . $this->getOption('tempListClose')."\n"; } //end of foreach //sort by category ksort($arr_out); foreach ($arr_out as $value) { //flush the buffer echo $value; } //plugin link if ($this->getOption('flg_pluglink') == 'yes') { $pluglink_url = $this->getURL(); $str_pversion = ''; //version check if ($this->canEdit()) { $chkver = $this->getLatestVersion($pluglink_url); if ($chkver > $this->getVersion()) { $str_pversion = " [Ver $chkver available]"; } } $ptitle = 'This is '. $this->getName().'('.$this->getVersion() .') » Go to distribution site'; echo ""; echo "» Get \"".$this->getName()."\"$str_pversion"; } } //end of function doSkinVar // helper function function canEdit() { global $member, $manager; if (!$member->isLoggedIn()) return 0; return $member->isAdmin(); } function getLatestVersion($url) { $name = $this->getShortName(); if ($_COOKIE[$name]) return 0; $fp = @fopen ($url, "r"); if ($fp){ $ref_str = fread($fp, 16384); if (eregi("(.*)", $ref_str, $out)) { setcookie($name,1,null,'/'); // set session cookie return $out[1]; } } return 0; } } //end of class ?> <%ArchiveIndex(5)%> //set item amount of each category on archive index <%ArchiveIndex(5,10,desc)%> //set page amount, show category description <%ArchiveIndex(5,10,none)%> //set page amount, don't show category description */ // plugin needs to work on Nucleus versions <=2.0 as well if (!function_exists('sql_table')){ function sql_table($name) { return 'nucleus_' . $name; } } class NP_ArchiveIndex extends NucleusPlugin { function getName() { return 'Archive Index'; } function getAuthor() { return 'nakahara21 + yu'; } function getURL() { return 'http://repository.datoka.jp/index.php?itemid=167'; } function getVersion() { return '0.77b'; } function getMinNucleusVersion() { return 200; } function supportsFeature($what) { switch($what){ case 'SqlTablePrefix': return 1; default: return 0; } } // a description to be shown on the installed plugins listing function getDescription() { return "Show all item title on archive list. [Optional] amount: limit the amount of links shown (e.g. if you only want to show 5 links on each list by category index). page amount: the amount of links in a page. show_catdesc: show category description. 'desc' or 'none'. Usage: <%ArchiveIndex%>, <%ArchiveIndex(5)%>, <%ArchiveIndex(5,10)%>, <%ArchiveIndex(5,10,desc)%>"; } function install() { if(getNucleusVersion() < 220) { $this->createOption('itemOrder','Order of title index. "time,DESC" or "time,ASC" or "title,DESC" or "title,ASC"','text','time,DESC'); $this->createOption('itemOrder2','Order of title(category selected). "time,DESC" or "time,ASC" or "title,DESC" or "title,ASC"','text','time,DESC'); } else { $this->createOption('itemOrder','Order of title index','select','time,DESC', 'title,DESC|title,DESC|title,ASC|title,ASC|time,DESC|time,DESC|time,ASC|time,ASC'); $this->createOption('itemOrder2','Order of title(category selected)','select','time,DESC', 'title,DESC|title,DESC|title,ASC|title,ASC|time,DESC|time,DESC|time,ASC|time,ASC'); } $this->createOption('catDesc','Show category description.','yesno','yes'); $this->createOption('idateFormat','Date format for item list','text','M d, Y'); $this->createOption('tempHead','Template: Header','text','

    #icatName#

    '); $this->createOption('tempHeadDesc','Template: Header(description)','text','
    #icatDesc#
    '); $this->createOption('tempListBegin','Template: List (begin)','text','
      '); $this->createOption('tempListElement','Template: List Element','text','
      #idet#

      '); $this->createOption('tempListClose','Template: List (close)','text','
    '); $this->createOption('flg_pluglink','Show plugin link (which works as version checker when logged as admin).','yesno','yes'); } function unInstall() { //nothing to do } function doSkinVar($skinType, $amount, $pamount=10, $show_catdesc='') { global $manager, $member, $blog, $CONF, $catid, $itemid; if (!is_numeric($amount)) $amount = 5; if (!is_numeric($pamount)) $pamount = 10; if ($show_catdesc == '') { if ($this->getOption('catDesc') == 'yes') $show_catdesc = 'desc'; else $show_catdesc = 'none'; } if ($blog) { $b =& $blog; } else { $b =& $manager->getBlog($CONF['DefaultBlog']); } $blogid = $b->getID(); if ($catid) { $this->linkparams = array('catid' => $catid); } //get value from request $page = intRequestVar('ap'); if ($catid) { $item_order = requestVar('ao'); //check value (also used to make flip link) list($itarget, $iorder) = @split(' ',$item_order); if(!($itarget=='time' or $itarget=='title' or $iorder =='desc' or $iorder =='asc')) { $item_order = $this->getOption('itemOrder2'); list($itarget, $iorder) = @split(',',$item_order); } } else { $item_order = $this->getOption('itemOrder'); list($itarget, $iorder) = @split(',',$item_order); } $iorder = strtolower($iorder); $now = time(); $idateformat = $this->getOption('idateFormat'); $archivedate = date('Y-m'); //get item data $query = 'SELECT inumber, ititle, icat, UNIX_TIMESTAMP(itime) as itime, iauthor FROM '.sql_table('item') . ' WHERE iblog=' . $blogid . ' and UNIX_TIMESTAMP(itime)<=' . $now // don't show future items! . ' and idraft=0'; // don't show draft items if ($catid) { $query .= ' and icat=' . intval($catid); //item count in the category $resnum = sql_query($query); $itemnum = mysql_num_rows($resnum); mysql_free_result($resnum); $pagemax = ceil($itemnum / $pamount); } if ($itarget == 'title') $query .= ' ORDER BY ititle'; else $query .= ' ORDER BY itime'; if ($iorder == 'asc') $query .= ' ASC'; else $query .= ' DESC'; if ($catid) { if ($page < 1) $page = 1; $poffset = ($page-1) * $pamount; $query .= " LIMIT $poffset,$pamount"; } $res = sql_query($query); //set data by category $list_cat = array(); $list_item = array(); while ($current = mysql_fetch_object($res)) { if (!$catid and count($list_cat[$current->icat]) > $amount) continue; //check the amount $inumber = $current->inumber; //itemid $idetail = date($idateformat, $current->itime); //itemdate $list_cat[$current->icat][] = $inumber; $list_item[$inumber]['ititle'] = htmlspecialchars(strip_tags($current->ititle)); $list_item[$inumber]['itemlink'] = createItemLink($inumber,$this->linkparams); $list_item[$inumber]['idetail'] = $idetail; } mysql_free_result($res); //show list by category $arr_out = array(); foreach ($list_cat as $icat => $arr_icat) { // buffer category name $icatName = $b->getCategoryName($icat); $icatDesc = $b->getCategoryDesc($icat); if ($show_catdesc == 'desc') $icatDescTitle = ''; // use for title prop. on header link else $icatDescTitle = $b->getCategoryDesc($icat); if (!$catid) $extra = array('catid' => $icat); else $extra = array(); $arclist_link = createArchiveListLink($blogid, $extra); $temp_head = $this->getOption('tempHead'); $temp_head = preg_replace('/#arclist_link#/',$arclist_link, $temp_head); $temp_head = preg_replace('/#icatName#/', $icatName, $temp_head); $temp_head = preg_replace('/#icatDesc#/', $icatDescTitle,$temp_head); $arr_out[$icatName] = $temp_head."\n"; if ($show_catdesc == 'desc') $temp_head_desc = $this->getOption('tempHeadDesc'); $temp_head_desc = preg_replace('/#icatDesc#/', $icatDesc, $temp_head_desc); $arr_out[$icatName] .= $temp_head_desc."\n"; $icnt = 0; $arr_title = array(); foreach ($arr_icat as $inumber) { //buffer item title $ititle = $list_item[$inumber]['ititle']; if (empty($ititle)) $ititle = '(no title)'; $itemlink = $list_item[$inumber]['itemlink']; $idetail = $list_item[$inumber]['idetail']; if ($icnt % 2 == 1) $bg = " class='stripe'"; else $bg = ''; $temp_list_el = $this->getOption('tempListElement'); $temp_list_el = preg_replace('/#bg#/', $bg, $temp_list_el); $temp_list_el = preg_replace('/#ilnk#/', $itemlink, $temp_list_el); $temp_list_el = preg_replace('/#itit#/', $ititle, $temp_list_el); $temp_list_el = preg_replace('/#idet#/', $idetail, $temp_list_el); $arr_title[] = $temp_list_el."\n"; $icnt++; if (!$catid and $icnt >= $amount) { //'more' link $extra = array('catid' => $icat); $arclist_link = createArchiveListLink($blogid, $extra); $arr_title[] = "
  • [ More... ]
  • \n"; break; } } if ($catid) { //make 'order switch' $itarget_flip = ($itarget=='title') ? 'time' : 'title'; //mode change $iorder_flip = ($iorder =='desc') ? 'asc' : 'desc'; //order change $itarget_flip_order = ($itarget_flip =='title') ? 'asc' : 'desc'; //ini-order on mode change if ($itarget == 'title') { $iorder_str = ($iorder == 'desc') ? 'Z-A' : 'A-Z'; $iorder_flip_str = ($iorder == 'desc') ? 'A-Z' : 'Z-A'; } else { //time $iorder_str = ($iorder == 'desc') ? 'New' : 'Old'; $iorder_flip_str = ($iorder == 'desc') ? 'Old' : 'New'; } $orderURL = serverVar('REQUEST_URI'); $orderURL = preg_replace('/[?&]ap=[0-9]*/','',$orderURL); //delete to add 'ap' param to last $orderURL = preg_replace('/[?&]ao=[^&0-9]*/','',$orderURL); if (strpos($orderURL,'?')===false) $orderURL .= "?ao="; else $orderURL .= "&ao="; $orderURL1 = $orderURL . "$itarget_flip+$itarget_flip_order&ap=".$page; $orderURL2 = $orderURL . "$itarget+$iorder_flip&ap=".$page; $pagenavi = "Sort: $itarget/$itarget_flip, "; $pagenavi.= "$iorder_str/$iorder_flip_str"; //make 'page link' $pagenavi.= "   Page: "; for ($i=1; $i<=$pagemax; $i++) { if ($i==$page) $pagenavi.= "$i "; else { $pageURL = serverVar('REQUEST_URI'); $pageURL = preg_replace('/([?&]ap=)[0-9]*/','',$pageURL); if (strpos($pageURL,'?')===false) $pageURL .= "?ap=$i"; else $pageURL .= "&ap=$i"; $pagenavi.= "[$i] "; } } //and make 'all category link' $arclist_link = createArchiveListLink($blogid); $arr_title[] = "
  • $pagenavi [ All Category ]
  • \n"; } $arr_out[$icatName] .= $this->getOption('tempListBegin')."\n" . join('',$arr_title) . $this->getOption('tempListClose')."\n"; } //end of foreach //sort by category ksort($arr_out); foreach ($arr_out as $value) { //flush the buffer echo $value; } //plugin link if ($this->getOption('flg_pluglink') == 'yes') { $pluglink_url = $this->getURL(); $str_pversion = ''; //version check if ($this->canEdit()) { $chkver = $this->getLatestVersion($pluglink_url); if ($chkver > $this->getVersion()) { $str_pversion = " [Ver $chkver available]"; } } $ptitle = 'This is '. $this->getName().'('.$this->getVersion() .') » Go to distribution site'; echo ""; echo "» Get \"".$this->getName()."\"$str_pversion"; } } //end of function doSkinVar // helper function function canEdit() { global $member, $manager; if (!$member->isLoggedIn()) return 0; return $member->isAdmin(); } function getLatestVersion($url) { $name = $this->getShortName(); if ($_COOKIE[$name]) return 0; $fp = @fopen ($url, "r"); if ($fp){ $ref_str = fread($fp, 16384); if (eregi("(.*)", $ref_str, $out)) { setcookie($name,1,null,'/'); // set session cookie return $out[1]; } } return 0; } } //end of class ?>
    <   2018-09   >
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30