Ejemplo n.º 1
0
 public function moduleRows($data)
 {
     $text = '';
     $tp = e107::getParser();
     $frm = e107::getForm();
     if (empty($data)) {
         return "\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='2'>" . LAN_EURL_EMPTY . "</td>\n\t\t\t\t</tr>\n\t\t\t";
     }
     $PLUGINS_DIRECTORY = e107::getFolder("PLUGINS");
     $srch = array("{SITEURL}", "{e_PLUGIN_ABS}");
     $repl = array(SITEURL, SITEURL . $PLUGINS_DIRECTORY);
     foreach ($data as $obj) {
         $admin = $obj->config->admin();
         $section = vartrue($admin['labels'], array());
         $rowspan = count($obj->locations) + 1;
         $module = $obj->module;
         $generate = vartrue($admin['generate'], array());
         /*
         			$info .= "
               <tr>
                   <td rowspan='$rowspan'><a class='e-tip' style='display:block' title='".LAN_EURL_LOCATION.$path."'>
                   ".vartrue($section['name'], eHelper::labelize($obj->module))."
                   </a></td>
              </tr>
           ";
         */
         $opt = "";
         $info = "<table class='table table-striped'>";
         foreach ($obj->locations as $index => $location) {
             $objSub = $obj->defaultLocation != $location ? eDispatcher::getConfigObject($obj->module, $location) : false;
             if ($objSub) {
                 $admin = $objSub->admin();
                 $section = vartrue($admin['labels'], array());
             } elseif ($obj->defaultLocation != $location) {
                 $section = array();
             }
             $id = 'eurl-' . str_replace('_', '-', $obj->module) . '-' . $index;
             $checked = varset($obj->current[$module]) == $location ? ' checked="checked"' : '';
             $path = eDispatcher::getConfigPath($module, $location, false);
             if (!is_readable($path)) {
                 $path = str_replace('/url.php', '/', $tp->replaceConstants(eDispatcher::getConfigPath($module, $location, true), true)) . ' <em>(' . LAN_EURL_LOCATION_NONE . ')</em>';
                 $diz = LAN_EURL_DEFAULT;
             } else {
                 $path = $tp->replaceConstants(eDispatcher::getConfigPath($module, $location, true), true);
                 $diz = basename($path) != 'url.php' ? LAN_EURL_FRIENDLY : LAN_EURL_DEFAULT;
             }
             $label = vartrue($section['label'], $index == 0 ? LAN_EURL_DEFAULT : eHelper::labelize(ltrim(strstr($location, '/'), '/')));
             $cssClass = $checked ? 'e-showme' : 'e-hideme';
             $cssClass = 'e-hideme';
             // always hidden for now, some interface changes could come after pre-alpha
             $exampleUrl = array();
             if (!empty($section['examples'])) {
                 foreach ($section['examples'] as $ex) {
                     $exampleUrl[] = str_replace($srch, $repl, $ex);
                 }
             }
             if (strpos($path, 'noid') !== false) {
                 //     $exampleUrl .= "  &nbsp; &Dagger;";    //XXX Add footer - denotes more CPU required. ?
             }
             $selected = varset($obj->current[$module]) == $location ? "selected='selected'" : '';
             $opt .= "<option value='{$location}' {$selected} >" . $diz . ": " . $exampleUrl[0] . "</option>";
             $info .= "<tr><td>" . $label . "\n\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\t\t<td><strong>" . LAN_EURL_LOCATION . "</strong>: " . $path . "\n                    <p>" . vartrue($section['description'], LAN_EURL_PROFILE_INFO) . "</p><small>" . implode("<br />", $exampleUrl) . "</small></td>\n                    \n                    \n                    \n                    </tr>\n\t\t\t\t";
         }
         $info .= "</table>";
         $title = vartrue($section['name'], eHelper::labelize($obj->module));
         $text .= "\n                <tr>\n                    <td>" . $this->moreInfo($title, $info) . "</td>\n                    <td><select name='eurl_config[{$module}]' class='input-block-level'>" . $opt . "</select></td>\n                    <td>";
         $bTable = $admin['generate']['table'];
         $bInput = $admin['generate']['input'];
         $bOutput = $admin['generate']['output'];
         $bPrimary = $admin['generate']['primary'];
         $text .= is_array($admin['generate']) ? $frm->admin_button('rebuild[' . $bTable . ']', $bPrimary . "::" . $bInput . "::" . $bOutput, 'delete', LAN_EURL_REBUILD) : "";
         $text .= "</td>\n               </tr>";
     }
     /*
     		For Miro - intuitive interface example. All configs are contained within one e_url.php file. 
     		Root namespacing automatically calculated based on selection. 
     		ie. choosing option 1 below will set root namespacing for news. 
     		Known bug (example): 
      News title: Nothing's Gonna Change my World!
      Currently becomes: /Nothing%26%23039%3Bs%20Gonna%20Change%20my%20World%21
     Should become: /nothings-gonna-change-my-world
     Good SEF reference: http://davidwalsh.name/generate-search-engine-friendly-urls-php-function
     
     [Miro] Solution comes from the module itself, not related with URL assembling in anyway (as per latest Skype discussion)
     */
     // Global On/Off Switch Example
     // [Miro] there is no reason of switch, everything could go through single entry point at any time, without a need of .htaccess (path info)
     // Control is coming per configuration file.
     $example = "\n\t\t<tr><td>Enable Search-Engine-Friendly URLs</td>\n\t\t<td><input type='checkbox' name='SEF-active' value='1' />\n\t\t</td></tr>";
     //Entry Example (Hidden unless the above global switch is active)
     $example .= "\n\t\t\n\t\t<tr><td>News</td>\n\t\t\t\t\t<td style='padding:0px'>\n\t\t\t\t\t<table style='width:600px;margin-left:0px'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />Default</td><td>/news.php?item.1</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />News Namespace and News Title</td><td>/news/news-item-title</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />Year and News Title</td><td>/2011/news-item-title</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />Year/Month and News Title</td><td>/2011/08/news-item-title</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />Year/Month/Day and News Title</td><td>/2011/08/27/news-item-title</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />News Category and News Title</td><td>/news-category/news-item-title</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t";
     // For 0.8 Beta
     $example .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />Custom</td><td><input class='tbox' type='text' name='custom-news' value='' /></td>\n\t\t\t\t\t\t</tr>";
     $example .= "</table>";
     $example .= "</td>\n\t\t\t\t\t</tr>";
     return $text;
 }
Ejemplo n.º 2
0
 /**
  * Convenient way to call config methods
  */
 public function configCallback($module, $callBack, $params, $location)
 {
     if (null == $location) {
         $location = eDispatcher::getModuleConfigLocation($module);
     }
     if (!$module || !($obj = eDispatcher::getConfigObject($module, $location))) {
         return false;
     }
     return call_user_func_array(array($obj, $callBack), $params);
 }