aliroSEFHelper Class Reference

List of all members.

Public Member Functions

 getConfig ($sefspace, $content_tasks)
 basicRetrieve ($uri, $config, $alirosef, $live_site)


Detailed Description

Definition at line 3 of file aliroSEFHelper.php.


Member Function Documentation

aliroSEFHelper::getConfig ( sefspace,
content_tasks 
)

Definition at line 5 of file aliroSEFHelper.php.

References aliroDatabase::getInstance().

00005                                                    {
00006         $config = new stdClass();
00007         $config->underscore = 0;
00008         $config->enabled = 1;
00009         $config->strip_chars = '';
00010         $config->lower_case = '0';
00011         $config->unique_id = '0';
00012         $config->cache_time = '600';
00013         $config->buffer_size = '500';
00014         $config->home_title = 'Home';
00015         $config->title_separator = '|';
00016         $config->default_robots = 'index, follow';
00017         $config->custom_code = array();
00018         $config->custom_name = array();
00019         $config->custom_PHP = array();
00020         $config->custom_short = array();
00021         $config->sef_content_task = array();
00022         $config->sef_name_chars = array();
00023         $config->sef_translate_chars = array();
00024         $config->component_details = array();
00025         $config->sef_substitutions_exact = array();
00026         $config->sef_substitutions_in = array();
00027         $config->sef_substitutions_out = array();
00028         $config->legal_content_tasks = array();
00029         $config->sef_name_chars = array('!', '?', '&', '/', ' ');
00030         $config->sef_translate_chars = array('', '', 'and', ' or ', $sefspace);
00031 
00032         $configdata = aliroDatabase::getInstance()->doSQLget ("SELECT * FROM #__remosef_config");
00033         foreach ($configdata as $item) {
00034             if ('options' == $item->type) {
00035                 $name = $item->name;
00036                 $config->$name = $item->modified;
00037             }
00038             elseif ('components' == $item->type) {
00039                 $config->custom_code[] = $item->name;
00040                 $config->custom_name[] = $item->modified;
00041             }
00042             elseif ('characters' == $item->type) {
00043                 $config->sef_name_chars[] = $item->name;
00044                 $config->sef_translate_chars[] = $item->modified;
00045             }
00046             elseif ('substitutions' == $item->type) {
00047                 $config->sef_substitutions_exact[$item->name] = $item->modified;
00048             }
00049             elseif ('substitutions_in' == $item->type) {
00050                 $config->sef_substitutions_in["#$item->name#i"] = $item->modified;
00051             }
00052             elseif ('substitutions_out' == $item->type) {
00053                 $config->sef_substitutions_out["#$item->name#i"] = $item->modified;
00054             }
00055             elseif ('content' == $item->type) $config->sef_content_task[$item->name] = $item->modified;
00056             else $config->component_details[$item->type][$item->name] = $item->modified;
00057         }
00058         unset($configdata);
00059         foreach ($content_tasks as $task) {
00060             $config->legal_content_tasks[] = isset($config->sef_content_task[$task]) ? $config->sef_content_task[$task] : $task;
00061         }
00062         foreach ($config->custom_code as $code) {
00063             $codefile = _ALIRO_CLASS_BASE."/components/$code/sef_ext.php";
00064             $seffile = dirname(__FILE__)."/sef_ext/$code/sef_ext.php";
00065             if (file_exists($codefile)) $config->custom_PHP[] = $codefile;
00066             elseif (file_exists($seffile)) $config->custom_PHP[] = $seffile;
00067             else $config->custom_PHP[] = false;
00068             $split = explode('_',$code);
00069             $config->custom_short[] = $split[1];
00070         }
00071         return $config;
00072     }

aliroSEFHelper::basicRetrieve ( uri,
config,
alirosef,
live_site 
)

Content /$option/$task/$sectionid/$id/$limit/$limitstart

Definition at line 74 of file aliroSEFHelper.php.

References $_REQUEST.

00074                                                                          {
00075         $url_array = explode('/', $uri);
00076         if (0 == strlen($url_array[0])) array_shift($url_array);
00077         if ($l = count($url_array) AND 0 == strlen($url_array[$l-1])) array_pop($url_array);
00078         $prefix = $subdir = '';
00079         $legal = array_merge(array ('content', 'component'), $config->custom_name, $config->legal_content_tasks);
00080         while (count($url_array)) {
00081             $element = array_shift($url_array);
00082             if ($element) {
00083                 if (in_array($element,$legal)) {
00084                     $prefix = $element;
00085                     break;
00086                 }
00087                 elseif (strpos($live_site, $element) === false) break;
00088                 else $subdir .= '/'.$element;
00089             }
00090         }
00091         $QUERY_STRING = '';
00092         $foundit = false;
00097         if ($prefix == 'content') {
00098             $foundit = true;
00099             $_REQUEST['option'] = $_GET['option'] = $option = 'com_content';
00100             // language hook for content
00101             $lang = "";
00102             $parms = array();
00103             foreach($url_array as $key=>$value) {
00104                 if ( strcasecmp(substr($value,0,5),'lang,') == 0 ) {
00105                     $parts = explode(",", $value);
00106                     if (count($parts) > 1) {
00107                         $lang = $_REQUEST['lang'] = $_GET['lang'] = $parts[1];
00108                     }
00109                 }
00110                 elseif (strlen($value)) $parms[] = $value;
00111             }
00112             // $option/$task/$sectionid/$id/$limit/$limitstart
00113             $task = $alirosef->untranslateContentTask($parms[0]);
00114             $_REQUEST['task'] = $_GET['task'] = $task;
00115             $QUERY_STRING .= "option=com_content&task=$task";
00116             if ($task == 'archivecategory') {
00117                 $_REQUEST['year'] = $_GET['year'] = $year = intval(@$parms[1]);
00118                 $_REQUEST['month'] = $_GET['month'] = $month = intval(@$parms[2]);
00119                 $_REQUEST['module'] = $_GET['module'] = $module = intval(@$parms[3]);
00120                 $QUERY_STRING .= "&year=$year&month=$month&module=$module";
00121             }
00122             else {
00123                 $num = count($parms);
00124                 for ($i = 1; $i <= $num-1; $i++) {
00125                     if (strcmp($parms[$i], (int)$parms[$i]) !== 0) return false;
00126                 }
00127                 $i = 1;
00128                 if (5 == $num OR 3 == $num) {
00129                     $_REQUEST['sectionid'] = $_GET['sectionid'] = $sectionid = $parms[$i];
00130                     $QUERY_STRING .= "&sectionid=$sectionid";
00131                     $i++;
00132                 }
00133                 if ($num > 1) {
00134                     $_REQUEST['id'] = $_GET['id'] = $id = $parms[$i];
00135                     $QUERY_STRING .= "&id=$id";
00136                 }
00137                 if ($num > 3) {
00138                     $_REQUEST['limit'] = $_GET['limit'] = $limit = $parms[$i+1];
00139                     $_REQUEST['limitstart'] = $_GET['limitstart'] = $limitstart = $parms[$i+2];
00140                     $QUERY_STRING .= "&limit=$limit&limitstart=$limitstart";
00141                 }
00142             }
00143             if ($lang!="") {
00144                 $QUERY_STRING .= "&lang=$lang";
00145             }
00146         }
00147 
00148         /*
00149         Components
00150         http://www.domain.com/component/$name,$value
00151         */
00152         elseif ($prefix == 'component') {
00153             $QUERY_STRING .= $alirosef->default_revert('component');
00154             if ($QUERY_STRING) $foundit = true;
00155         }
00156         else {
00157             // Wouldn't be necessary, but wanted to avoid negative parameter to sef_ext.php
00158             array_unshift ($url_array, $prefix);
00159             array_unshift ($url_array, 'dummy');
00160             foreach ($config->custom_name as $i=>$compname) {
00161                 if (isset($url_array[1]) AND $url_array[1] == $compname) {
00162                     $origname = $config->custom_code[$i];
00163                     if ($config->custom_PHP[$i] AND file_exists($config->custom_PHP[$i])) {
00164                         if (isset($url_array[2]) AND $url_array[2]) {
00165                             $customsef = $alirosef->invoke_plugin($i, 'revert', $url_array, 0);
00166                             if ($customsef) $QUERY_STRING .= 'option='.$origname.$customsef;
00167                             else return false;
00168                         }
00169                         else $QUERY_STRING .= 'option='.$origname;
00170                     }
00171                     else $QUERY_STRING .= 'option='.$origname.$alirosef->default_revert($compname);
00172                     $_REQUEST['option'] = $_GET['option'] = $option = $origname;
00173                     $foundit = true;
00174                     break;
00175                 }
00176             }
00177             if (!$foundit AND isset($url_array[1])) {
00178                 $content_sef = _ALIRO_CLASS_BASE.'/components/com_content/sef_ext.php';
00179                 if (file_exists($content_sef)) {
00180                     require_once($content_sef);
00181                     $crevert = sef_content::revert($url_array,0);
00182                     if ($crevert) {
00183                         $foundit = true;
00184                         $QUERY_STRING .= $crevert;
00185                     }
00186                 }
00187             }
00188         }
00189         if ($foundit) return $QUERY_STRING;
00190         else return false;
00191     }


The documentation for this class was generated from the following file:

Generated on Wed May 14 13:02:00 2008 for ALIRO by  doxygen 1.5.5