1
wishcraft
Preloaders: Perfect xoops_sef(); utf8, utf16... supportive!!

<?php /** * Xoops_sef Preloads & Language Stylesheet loader * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Cointin Maxime (AKA Kraven30) * @author Andricq Nicolas (AKA MusS) * @version $Id: Sef.php 12537 2014-05-19 14:19:33Z beckmi $ */ if (!function_exists('xoops_sef')) { /** * Xoops safe encoded url elements * * @param unknown $datab * @param string $char * @return string */ function xoops_sef($datab, $char ='-') { $replacement_chars = array(); $accepted = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","m","o","p","q", "r","s","t","u","v","w","x","y","z","0","9","8","7","6","5","4","3","2","1"); for($i=0;$i<256;$i++){ if (!in_array(strtolower(chr($i)),$accepted)) $replacement_chars[] = chr($i); } $return_data = (str_replace($replacement_chars,$char,($datab))); while(substr($return_data, 0, 1) == $char) $return_data = substr($return_data, 1, strlen($return_data)-1); while(substr($return_data, strlen($return_data)-1, 1) == $char) $return_data = substr($return_data, 0, strlen($return_data)-1); while(strpos($return_data, $char . $char)) $return_data = str_replace($char . $char, $char, $return_data); return(strtolower($return_data)); } } /** * Class ModuleSefPreload */ class ModuleSefPreload extends XoopsPreloadItem { /** * * @param array $arg */ function eventCoreHeaderAddmeta($arg) { $parts = explode(DIRECTORY_SEPARATOR, $_SERVER['PHP_SELF']); $moddir = basename(dirname(dirname(__FILE__))); if (in_array($moddir, $parts)) $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/' . $moddir . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/' . $moddir . '.css', array(), '' ); } }


The great thing about this code is the xoops_sef... allows for arabic URLS with mixed english etc..

Made while working on a new front portal for Chronolabs at http://web.au.labs.coop

2
wishcraft
Re: Preloaders: Perfect xoops_sef(); utf8, utf16... supportive!!

Come on guys there is only one change needed in it, 118 views and no one corrected, common zealots..

<?php /** * Xoops_sef Preloads & Language Stylesheet loader * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author Cointin Maxime (AKA Kraven30) * @author Andricq Nicolas (AKA MusS) * @version $Id: Sef.php 12537 2014-05-19 14:19:33Z beckmi $ */ if (!function_exists('xoops_sef')) { /** * Xoops safe encoded url elements * * @param unknown $datab * @param string $char * @return string */ function xoops_sef($value = '', $stripe ='-') { $replacement_chars = array(); $accepted = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","m","o","p","q", "r","s","t","u","v","w","x","y","z","0","9","8","7","6","5","4","3","2","1"); for($i=0;$i<256;$i++){ if (!in_array(strtolower(chr($i)),$accepted)) $replacement_chars[] = chr($i); } $result = (str_replace($replacement_chars, $stripe, ($value))); while(substr($result, 0, strlen($stripe)) == $stripe) $result = substr($result, strlen($stripe), strlen($result) - strlen($stripe)); while(substr($result, strlen($result) - strlen($stripe), strlen($stripe)) == $stripe) $result = substr($result, 0, strlen($result) - strlen($stripe)); while(strpos($result, $stripe . $stripe)) $result = str_replace($stripe . $stripe, $stripe, $result); return(strtolower($result)); } } /** * Class ModuleSefPreload */ class ModuleSefPreload extends XoopsPreloadItem { /** * * @param array $arg */ function eventCoreHeaderAddmeta($arg) { $parts = explode(DIRECTORY_SEPARATOR, $_SERVER['PHP_SELF']); $moddir = basename(dirname(dirname(__FILE__))); if (in_array($moddir, $parts)) $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/' . $moddir . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/' . $moddir . '.css', array(), '' ); } }

3
timgno
Re: Preloaders: Perfect xoops_sef(); utf8, utf16... supportive!!
  • 2015/2/12 10:20

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


This could also serve as a service cron jobs?

4
wishcraft
Re: Preloaders: Perfect xoops_sef(); utf8, utf16... supportive!!

If your wondering what SEF stands for it is an SEO function for URL generation that stands for 'Search Engine Friendly'!

Preloaders should not really be thought about as a 'cron' this is what is called a hooking stratum, which is how Microsoft windows events and processings works unlike linux. This is where is was adopted from.

This file is normally called sef.php in the modules/dirname/preloaders path from memory... it will load a css style sheet from modules/language/dirname as dirname.css in modules.

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!