Пример #1
0
 function Command($cmd)
 {
     global $page;
     $this->IsProtected($page->gp_index);
     if (common::loggedIn()) {
         $page->admin_links[] = common::Link($page->title, 'Page Protect', 'cmd=passprotect', 'name="gpajax"');
         return $this->Admin($cmd, $page->gp_index);
     }
     if (!$this->is_protected) {
         return $cmd;
     }
     //if protected,
     $page->contentBuffer = $this->config['content'];
     return 'return';
 }
Пример #2
0
 /**
  * Prepare and output the Javascript for the current page
  * @static
  */
 static function GetHead_JS($scripts)
 {
     global $page, $config;
     $placeholder = '<!-- jquery_placeholder ' . gp_random . ' -->';
     $keys_before = array_keys($scripts);
     $combine = $config['combinejs'] && !common::loggedIn() && $page->pagetype !== 'admin_display';
     //just jQuery
     if (!count($page->head_js) && count($scripts) < 2) {
         echo $placeholder;
         return;
     }
     //remote jquery
     if ($config['jquery'] != 'local') {
         echo $placeholder;
         unset($scripts['jquery']);
     }
     //jquery ui
     if ($config['jquery'] == 'jquery_ui') {
         $has_jquery_ui = false;
         foreach ($scripts as $key => $script) {
             if (isset($script['package']) && $script['package'] == 'jquery_ui') {
                 $has_jquery_ui = true;
                 unset($scripts[$key]);
             }
         }
         if ($has_jquery_ui) {
             echo "\n<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js\"></script>";
         }
     }
     if (!$combine || $page->head_force_inline) {
         echo "\n<script type=\"text/javascript\">";
         common::jsStart();
         echo '</script>';
     }
     if (is_array($page->head_js)) {
         $scripts += $page->head_js;
         //other js files
     } else {
         trigger_error('$page->head_js is not an array');
     }
     gpOutput::CombineFiles($scripts, 'js', $combine);
 }
Пример #3
0
 /**
  * Return the beginning content of a data file
  *
  */
 public static function FileStart($file, $time = null, $file_stats = array())
 {
     global $gpAdmin;
     if (is_null($time)) {
         $time = time();
     }
     //file stats
     $file_stats = (array) $file_stats + gpFiles::GetFileStats($file);
     $file_stats['gpversion'] = gpversion;
     $file_stats['modified'] = $time;
     if (common::loggedIn()) {
         $file_stats['username'] = $gpAdmin['username'];
     } else {
         $file_stats['username'] = false;
     }
     return '<' . '?' . 'php' . "\ndefined('is_running') or die('Not an entry point...');" . "\n" . '$fileVersion = \'' . gpversion . '\';' . "\n" . '$fileModTime = \'' . $time . '\';' . "\n" . gpFiles::ArrayToPHP('file_stats', $file_stats) . "\n\n";
 }
Пример #4
0
 /**
  * Display the links at the bottom of a post
  *
  */
 public function PostLinks()
 {
     $post_key = SimpleBlogCommon::AStrKey('str_index', $this->post_id);
     echo '<p class="blog_nav_links">';
     //blog home
     $html = common::Link('Special_Blog', '%s', '', 'class="blog_home"');
     echo gpOutput::GetAddonText('Blog Home', $html);
     echo '&nbsp;';
     // check for newer posts and if post is draft
     $isDraft = false;
     if ($post_key > 0) {
         $i = 0;
         do {
             $i++;
             $next_index = SimpleBlogCommon::AStrGet('str_index', $post_key - $i);
             if (!common::loggedIn()) {
                 $isDraft = SimpleBlogCommon::AStrGet('drafts', $next_index);
             }
         } while ($isDraft);
         if (!$isDraft) {
             $html = SimpleBlogCommon::PostLink($next_index, '%s', '', 'class="blog_newer"');
             echo gpOutput::GetAddonText('Newer Entry', $html);
             echo '&nbsp;';
         }
     }
     //check for older posts and if older post is draft
     $i = 0;
     $isDraft = false;
     do {
         $i++;
         $prev_index = SimpleBlogCommon::AStrGet('str_index', $post_key + $i);
         if ($prev_index === false) {
             break;
         }
         if (!common::loggedIn()) {
             $isDraft = SimpleBlogCommon::AStrGet('drafts', $prev_index);
         }
         if (!$isDraft) {
             $html = SimpleBlogCommon::PostLink($prev_index, '%s', '', 'class="blog_older"');
             echo gpOutput::GetAddonText('Older Entry', $html);
         }
     } while ($isDraft);
     if (common::LoggedIn()) {
         echo '&nbsp;';
         echo common::Link('Admin_Blog', 'New Post', 'cmd=new_form', 'class="blog_post_new"');
     }
     echo '</p>';
 }
Пример #5
0
/**
 * Output the message buffer
 *
 */
function GetMessages()
{
    global $wbMessageBuffer, $gp_not_writable, $langmessage;
    if (common::loggedIn() && count($gp_not_writable) > 0) {
        $files = '<ul><li>' . implode('</li><li>', $gp_not_writable) . '</li></ul>';
        $message = sprintf($langmessage['not_writable'], common::GetUrl('Admin_Status')) . $files;
        message($message);
    }
    if (!empty($wbMessageBuffer)) {
        $result = '';
        foreach ($wbMessageBuffer as $args) {
            if (!isset($args[0])) {
                continue;
            }
            if (isset($args[1])) {
                $result .= '<li>' . call_user_func_array('sprintf', $args) . '</li>';
            } else {
                $result .= '<li>' . $args[0] . '</li>';
            }
        }
        //$result = str_replace('%s',' ',$result);
        $wbMessageBuffer = array();
        echo '<div class="messages"><div>';
        echo '<a style="" href="#" class="req_script close_message" name="close_message"></a>';
        echo '<ul>' . $result . '</ul></div></div>';
    }
    common::ErrorBuffer();
}
Пример #6
0
 /**
  * Gadget Function
  * Show related titles
  *
  */
 function Gadget()
 {
     global $page, $ml_languages, $config, $addonRelativeCode;
     if ($page->pagetype == 'display') {
         $page->admin_links[] = common::Link('Admin_MultiLang', 'Multi Language', 'cmd=title_settings&index=' . $page->gp_index, ' name="gpabox"');
     }
     $page->head_js[] = $addonRelativeCode . '/script.js';
     //needed for admin pages as well
     $page->css_admin[] = $addonRelativeCode . '/admin.css';
     $list = $this->GetList($page->gp_index);
     //admin and special pages cannot be translated
     if ($page->pagetype != 'display') {
         return;
     }
     if (!$list && !common::loggedIn()) {
         return;
     }
     //show the list
     echo '<div class="multi_lang_select"><div>';
     echo '<b>Languages</b>';
     echo '<ul>';
     foreach ($ml_languages as $lang_code => $lang_label) {
         if (!isset($list[$lang_code])) {
             continue;
         }
         $index = $list[$lang_code];
         if ($index == $page->gp_index) {
             continue;
         }
         $title = common::IndexToTitle($index);
         echo '<li>';
         echo common::Link($title, $lang_label);
         echo '</li>';
     }
     if (common::loggedIn()) {
         echo '<li>';
         echo common::Link('Admin_MultiLang', 'Add Language', 'cmd=title_settings&index=' . $page->gp_index, ' name="gpabox"');
         echo '</li>';
     }
     echo '</ul>';
     echo '</div></div>';
 }
Пример #7
0
/**
 * Output the message buffer
 *
 */
function GetMessages($wrap = true)
{
    global $wbMessageBuffer, $gp_not_writable, $langmessage;
    if (common::loggedIn() && count($gp_not_writable) > 0) {
        $files = '<ul><li>' . implode('</li><li>', $gp_not_writable) . '</li></ul>';
        $message = sprintf($langmessage['not_writable'], common::GetUrl('Admin_Status')) . $files;
        message($message);
        $gp_not_writable = array();
    }
    $result = $wrap_end = '';
    if ($wrap) {
        $result = "\n<!-- message_start " . gp_random . " -->";
        $wrap_end = "<!-- message_end -->\n";
    }
    if (!empty($wbMessageBuffer)) {
        if (gpdebug === false) {
            $wbMessageBuffer = array_unique($wbMessageBuffer);
        }
        $result .= '<div class="messages"><div>';
        $result .= '<a style="" href="#" class="req_script close_message" data-cmd="close_message"></a>';
        $result .= '<ul>';
        $result .= implode('', $wbMessageBuffer);
        $result .= '</ul></div></div>';
    }
    return $result .= common::ErrorBuffer() . $wrap_end;
}
Пример #8
0
 public function Gadget()
 {
     global $page;
     $this->AddResources();
     //admin and special pages cannot be translated
     if ($page->pagetype != 'display') {
         return;
     }
     $list = $this->GetList($page->gp_index);
     if (!$list && !common::loggedIn()) {
         return;
     }
     $current_page_lang = array_search($page->gp_index, $list);
     //show the list
     echo '<div class="multi_lang_select"><div>';
     echo '<b>Languages</b>';
     $links = array();
     foreach ($this->avail_langs as $lang_code => $lang_label) {
         if (!isset($list[$lang_code])) {
             continue;
         }
         if ($lang_code == $current_page_lang) {
             continue;
         }
         $index = $list[$lang_code];
         $title = common::IndexToTitle($index);
         $links[] = common::Link($title, $lang_label);
     }
     if ($links) {
         echo '<ul><li>';
         echo implode('</li><li>', $links);
         echo '</li></ul>';
     }
     if (common::loggedIn()) {
         echo '<p>Admin: ';
         echo common::Link('Admin_MultiLang', 'Add Translation', 'cmd=TitleSettings&index=' . $page->gp_index, ' name="gpabox"');
         echo '</p>';
     }
     echo '</div></div>';
 }