/** * Simple jQuery Plugin Loader */ function initJSPlugin($plugin = '') { $plugin = 'jquery.' . $plugin . '.js'; if (empty($GLOBALS['block']['custom_htmlhead'][$plugin])) { initJSLib(); $GLOBALS['block']['custom_htmlhead'][$plugin] = getJavaScriptSourceLink(TEMPLATE_PATH . 'lib/jquery/plugin/' . $plugin); } return TRUE; }
/** * Simple MooTools Plugin Loader */ function initJSPlugin($plugin = '', $more = false) { // enhance teplate JS parser for MooTools More // sample: <!-- JS: MORE:Fx/Fx.Elements,Fx/Fx.Accordion --> if (is_string($plugin) && $more === false && substr(strtoupper($plugin), 0, 5) == 'MORE:') { $plugin = trim(substr($plugin, 5)); $more = true; } if ($more === false) { $plugin = 'mootools.' . $plugin . '.js'; if (empty($GLOBALS['block']['custom_htmlhead'][$plugin])) { initJSLib(); $GLOBALS['block']['custom_htmlhead'][$plugin] = getJavaScriptSourceLink(TEMPLATE_PATH . 'lib/mootools/plugin-1.4/' . $plugin); } } else { // Load MooTools More Plugins - simple Wrapper 'Fx/Fx.Slide,Fx/Fx.Scroll...' // it does not check dependents if (!is_array($plugin)) { $plugin = convertStringToArray($plugin); } if (count($plugin)) { initJSLib(); // add mootools more core array_unshift($plugin, 'More/More'); foreach ($plugin as $more) { if (empty($GLOBALS['block']['custom_htmlhead'][$more]) && is_file(PHPWCMS_TEMPLATE . 'lib/mootools/more-1.4/' . $more . '.js')) { $GLOBALS['block']['custom_htmlhead'][$more] = getJavaScriptSourceLink(TEMPLATE_PATH . 'lib/mootools/more-1.4/' . $more . '.js'); } } } } return TRUE; }
/** * render <!-- JS: PluginName|my.js //Whatever text --> */ function renderHeadJS($js) { if (is_array($js) && isset($js[1])) { $js = $js[1]; } $js = trim($js); if (empty($js)) { return ''; } $remote = substr($js, 0, 4) == 'http' ? true : false; if (!$remote && (strpos($js, ';') !== false || strpos($js, '//') !== false || strpos($js, '/*') !== false)) { $key = md5($js); // add the same section only once if (empty($GLOBALS['block']['custom_htmlhead'][$key])) { $GLOBALS['block']['custom_htmlhead'][$key] = ' <script' . SCRIPT_ATTRIBUTE_TYPE . '>' . LF . SCRIPT_CDATA_START . LF . ' '; $GLOBALS['block']['custom_htmlhead'][$key] .= $js; $GLOBALS['block']['custom_htmlhead'][$key] .= LF . SCRIPT_CDATA_END . LF . ' </script>'; } } elseif ($js == 'initJSLib') { initJSLib(); } elseif ($remote || which_ext($js) == 'js') { // decide if plugin or script // replace {TEMPLATE} $js = str_replace('{TEMPLATE}', TEMPLATE_PATH, $js); $GLOBALS['block']['custom_htmlhead'][md5($js)] = getJavaScriptSourceLink(html_specialchars($js)); } else { initJSLib(); if (strtolower($js) != 'initlib') { initJSPlugin($js); } } return ''; }
function getFrontendEditLink($type = '', $id_1 = 0, $id_2 = 0, $uid = 0) { // check if frontend edit link allowed if (!FE_EDIT_LINK) { return ''; } // init JSLib initJSLib(); // set specific frontend editing link set_css_link('inc_css/specific/frontend_edit.css'); $link = ''; $href = ''; $title = ''; switch ($type) { case 'article': $href = 'do=articles&p=2&s=1&id=' . $id_1; $title = '@@Backend: goto Article@@'; break; case 'summary': $href = 'do=articles&p=2&s=1&aktion=1&id=' . $id_1; $title = '@@Backend: edit Article Summary@@'; break; //enym new edit structure //enym new edit structure case 'structure': if (isset($GLOBALS['content']['struct'][$id_1]['acat_struct'])) { $href = 'do=admin&p=6&struct='; $href .= $id_1 ? $GLOBALS['content']['struct'][$id_1]['acat_struct'] . '&cat=' . $id_1 : 'index'; $title = '@@Backend: edit Structure Level@@'; } break; case 'CP': if (!$_SESSION["wcs_user_admin"] && $id_1) { $sql = 'SELECT COUNT(*) FROM ' . DB_PREPEND . 'phpwcms_article WHERE article_id=' . _dbEscape($id_1); $sql .= ' AND article_uid=' . _dbEscape($_SESSION["wcs_user_id"]); if (!_dbCount($sql)) { return ''; } } $href = 'do=articles&p=2&s=1&aktion=2&id=' . $id_1 . '&acid=' . $id_2; $title = '@@Backend: edit Content Part@@'; break; //enym new block to make news items editable //enym new block to make news items editable case 'news': $href = 'do=articles&p=3&cntid=' . $id_1 . '&action=edit'; $title = '@@Backend: edit News@@'; break; //end enym //end enym case 'module': if (!$_SESSION["wcs_user_admin"] && $id_2) { $sql = 'SELECT COUNT(*) FROM ' . DB_PREPEND . 'phpwcms_article WHERE article_id=' . _dbEscape($id_2); $sql .= ' AND article_uid=' . _dbEscape($_SESSION["wcs_user_id"]); if (!_dbCount($sql)) { return ''; } } $href = 'do=modules&module=' . $id_1; $title = '@@Backend: goto Module@@'; break; } if ($href) { $link = '<a href="' . PHPWCMS_URL . 'phpwcms.php?' . $href . '" target="backend" '; $link .= 'class="fe-link fe-' . $type . '" title="' . $title . '">'; $link .= '<span>' . $title . '</span></a> '; } return $link; }