Пример #1
0
 public static function news($toUser, $newList)
 {
     /*
     $newList = array(
         array(
             'title'=> '"Happy Day',
             'description'=> 'Is Really A Happy Day',
             'url'=> 'URL',
             'picurl'=> 'PIC_URL',
         ),
         array(
             'title'=> 'Happy Day',
             'description'=> 'Is Really A Happy Day',
             'url'=> 'URL',
             'picurl'=> 'PIC_URL',
         ),
     );
     */
     if (count($newList) > 10) {
         href('图文数量超过10条');
         exit;
     }
     $data = array('touser' => $toUser, 'msgtype' => 'news', 'news' => array('articles' => $newList));
     self::doCurl($data);
 }
Пример #2
0
 public static function uploadNews($articles)
 {
     /* 传入data实例
        $articles[] = array(
            'thumb_media_id'=> $media_id,
            'author'=> '天王盖地虎',
            'title'=> '这个我的测试消息',
            'content_source_url'=> 'our-class.cn',
            'content'=> '这是一个图文摘要',
            'digest'=> '',
            'show_cover_pic'=> 1,
        );
        $articles[] = array(
            'thumb_media_id'=> $media_id,
            'author'=> '天王盖地虎',
            'title'=> '这个我的测试消息',
            'content_source_url'=> 'our-class.cn',
            'content'=> '这是一个图文摘要',
            'digest'=> '',
            'show_cover_pic'=> 1,
        );
        */
     $url = 'https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=' . AccessToken::getAccessToken();
     if (count($articles) > 10) {
         href('文章总数大于10');
         return false;
     }
     $data = array('articles' => $articles);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res['media_id'];
 }
Пример #3
0
function whole_page()
{
    global $domain;
    $output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    $output .= "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
    $output .= "<channel>\n";
    $output .= "  <title>Stacks project -- Comments</title>\n";
    $output .= "  <link>";
    $output .= $domain . href('comments-feed.rss');
    $output .= "</link>\n";
    $output .= "  <description>Stacks project, see http://stacks.math.columbia.edu</description>\n";
    $output .= "  <language>en</language>\n";
    $output .= "  <managingEditor>stacks.project@gmail.com (Stacks Project)</managingEditor>\n";
    $output .= "  <webMaster>pieterbelmans@gmail.com (Pieter Belmans)</webMaster>\n";
    $output .= "  <image>\n";
    $output .= "    <url>";
    $output .= $domain . href('stacks.png');
    $output .= "</url>\n";
    $output .= "    <title>Stacks project -- Comments</title>\n";
    $output .= "    <link>";
    $output .= $domain . href('comments-feed.rss');
    $output .= "</link>\n";
    $output .= "  </image>\n";
    $output .= print_comments_feed(10);
    $output .= "</channel>\n";
    $output .= "</rss>";
    return $output;
}
Пример #4
0
/**
 * The main Page editor panel.
 *
 * @param string|array $message The activity message
 */
function page_edit($message = '')
{
    global $event, $step;
    pagetop(gTxt('edit_pages'), $message);
    extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew'))));
    $name = sanitizeForPage(assert_string(gps('name')));
    $newname = sanitizeForPage(assert_string(gps('newname')));
    if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) {
        $name = safe_field('page', 'txp_section', "name = 'default'");
    } elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) {
        $name = $newname;
    }
    $buttons = n . tag(gTxt('page_name'), 'label', array('for' => 'new_page')) . br . fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true);
    if ($name) {
        $buttons .= span(href(gTxt('duplicate'), '#', array('id' => 'txp_clone', 'class' => 'clone', 'title' => gTxt('page_clone'))), array('class' => 'txp-actions'));
    } else {
        $buttons .= hInput('savenew', 'savenew');
    }
    $html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html');
    // Format of each entry is popTagLink -> array ( gTxt() string, class/ID).
    $tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags'));
    $tagbuild_links = '';
    foreach ($tagbuild_items as $tb => $item) {
        $tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]);
    }
    echo hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading'));
    echo n . tag(n . tag(hed(gTxt('tagbuilder'), 2) . $tagbuild_links, 'div', array('id' => 'tagbuild_links', 'class' => 'txp-layout-cell txp-layout-1-4')) . n . tag(form(graf($buttons) . graf(tag(gTxt('page_code'), 'label', array('for' => 'html')) . br . '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>') . graf(fInput('submit', '', gTxt('save'), 'publish') . eInput('page') . sInput('page_save') . hInput('name', $name)), '', '', 'post', 'edit-form', '', 'page_form'), 'div', array('id' => 'main_content', 'class' => 'txp-layout-cell txp-layout-2-4')) . n . tag(graf(sLink('page', 'page_new', gTxt('create_new_page')), ' class="action-create"') . page_list($name) . n, 'div', array('id' => 'content_switcher', 'class' => 'txp-layout-cell txp-layout-1-4')) . n, 'div', array('id' => $event . '_container', 'class' => 'txp-layout-grid'));
}
Пример #5
0
function getCenterPiece(&$centerpiece, &$centerpiecelinks)
{
    $user =& atkGetUser();
    $theme =& atkinstance("atk.ui.atktheme");
    // Set the dispatchfile for this menu based on the theme setting, or to the default if not set.
    // This makes sure that all calls to dispatch_url will generate a url for the main frame and not
    // within the menu itself.
    $dispatcher = $theme->getAttribute('dispatcher', atkconfig("dispatcher", "index.php"));
    // do not use atkSelf here!
    $c =& atkinstance("atk.atkcontroller");
    $c->setPhpFile($dispatcher);
    if ($theme->getAttribute('useframes', true)) {
        $target = 'target="main"';
    } else {
        $target = "";
    }
    //$centerpiece = $centerpiecelinks['pim'] = href(dispatch_url("dashboard.mainboard", "start"), atktext("pim"), SESSION_NEW, false,$target);
    // change location link - if location_name is null there is only one location!
    if ($user['location_id'] !== null) {
        $current_location = atktext('current_location') . ': ' . $user['location_name'];
        $atktarget = "index.php?atknodetype=locations.location&atkaction=change&atklevel=0&atkprevlevel=0&atkselect=[atkprimkey]";
        $params = array("atkfilter" => $filter, "atktarget" => $atktarget);
        $centerpiece = $centerpiecelinks['change_location'] = href(dispatch_url("locations.location", "select", $params), $current_location, SESSION_NEW, false, $target);
    }
    // if user settings is allowed put link to it
    if (is_allowed("loginmanager.settings", "edit") && substr($user['name'], 0, 4) != 'demo') {
        $centerpiece .= '&nbsp; &nbsp; &nbsp;';
        $centerpiece .= $centerpiecelinks['userprefs'] = href(dispatch_url("loginmanager.settings", "edit"), atktext("userprefs"), SESSION_NEW, false, $target);
    }
}
Пример #6
0
 private function printResult($result, $includeProofs)
 {
     $output = "";
     switch ($result["type"]) {
         case "item":
             $parent = getEnclosingTag($result["position"]);
             $section = getEnclosingSection($result["position"]);
             // enumeration can live in sections, hence we should take care of this sidecase
             if ($parent["tag"] == $section["tag"]) {
                 $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . "</a> of the enumeration in <a href='" . href("tag/" . $section["tag"]) . "'>" . ucfirst($section["type"]) . " " . $section["book_id"] . "</a></p>";
             } else {
                 $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . "</a> of the enumeration in <a href='" . href("tag/" . $parent["tag"]) . "'>" . ucfirst($parent["type"]) . " " . $parent["book_id"] . "</a> in <a href='" . href("tag/" . $section["tag"]) . "'>" . "Section " . $section["book_id"] . ": " . parseAccents($section["name"]) . "</a></p>";
             }
             break;
         case "section":
             $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . ((!empty($result["name"]) and $result["type"] != "equation") ? ": " . parseAccents($result["name"]) . "</a>" : "</a>") . "</p>";
             break;
         default:
             $section = getEnclosingSection($result["position"]);
             $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . ((!empty($result["name"]) and $result["type"] != "equation") ? ": " . parseAccents($result["name"]) . "</a>" : "</a>") . " in <a href='" . href("tag/" . $section["tag"]) . "'>" . "Section " . $section["book_id"] . ": " . parseAccents($section["name"]) . "</a></p>";
             break;
     }
     if (!in_array($result["type"], array("section", "subsection"))) {
         if ($includeProofs) {
             $output .= "<pre class='preview' id='text-" . $result["tag"] . "'>" . parsePreview($result["text"]) . "</pre>";
         } else {
             $output .= "<pre class='preview' id='text-" . $result["tag"] . "'>" . parsePreview($result["text_without_proofs"]) . "</pre>";
         }
     }
     return $output;
 }
Пример #7
0
/**
 * Формирование ссылок.
 * 
 * @param string $text
 * @param string $query
 * @param string $attribute
 * @param bool $abs
 *
 * @return string 
 */
function linkTo(...$args)
{
    $default = ['attribute' => null, 'abs' => false];
    $args = array_merge($default, $args);
    extract($args);
    return '<a href="' . href($query, $abs) . '" ' . $attribute . ' >' . htmlspecialchars($text) . '</a>';
}
Пример #8
0
function wlist()
{
    $lines = null;
    $args = func_get_args();
    switch ($args[0]) {
        case 'scan':
            if ($elements = scan_dir($args[2]['path'], 'DIR')) {
                foreach ($elements as $value) {
                    if (is_file($args[2]['path'] . $value . $args[2]['find'])) {
                        $about = @parse_ini_file($args[2]['path'] . $value . '/protocol/about.gl.php');
                        $name = $about['product'] ? $about['product'] : $value;
                        $lines[$name] = $args[3] ? href(THIS, $args[3], $value) : href($value);
                        unset($about);
                    }
                }
            }
            break;
        default:
            if (is_array($args[2])) {
                foreach ($args[2] as $link => $name) {
                    $lines[$link] = href(THIS, $args[3], $name);
                }
            }
            break;
    }
    //Выводим массив ссылок ;)
    if ($lines) {
        foreach ($lines as $name => $link) {
            form("label", icon($args[1]) . '<a href="' . $link . '">' . $name . '</a>');
        }
    } else {
        html('<br> Wlist lib. (C) Kazin Fedor, 2010');
    }
}
Пример #9
0
 public function getMain()
 {
     global $config;
     $value = "";
     $value .= "<h2><a href='" . href("about") . "'>About</a></h2>";
     $value .= "<p>This is the home page of the Stacks project. It is an open source textbook and reference work on algebraic stacks and the algebraic geometry needed to define them. For more general information see our extensive <a href='" . href("about") . "'>about page</a>.</p>";
     $value .= "<h2><a href='" . href("contribute") . "'>How to contribute?</a></h2>";
     $value .= "<p>The Stacks project is a collaborative effort. There is a <a href='https://github.com/stacks/stacks-project/blob/master/CONTRIBUTORS'>list of people who have contributed so far</a>. While browsing the Stacks project please provide feedback by leaving a comment. Another option is to suggest slogans for results. For more details please visit the <a href='/contribute'>contribute page</a>.</p>";
     $value .= "<h2><a href='" . href("browse") . "'>Browsing and downloads</a></h2>";
     $value .= "<p>The entire project in <a href='download/book.pdf'>one pdf file</a>. You can also <a href='" . href("browse") . "'>browse the project online</a>, and there is a tree view which starts at <a href='" . href("chapter/1") . "'>Chapter 1</a>. To download the source files there is <a href='https://github.com/stacks/stacks-project/'>stacks/stacks-project</a> at GitHub.</p>";
     $value .= "<h2><a href='" . href("tag") . "'>Looking up tags</a></h2>";
     $value .= "<p>You can search the Stacks project by keywords:";
     $value .= getSimpleSearchForm();
     $value .= "<p>If you on the other hand have a tag for an item (which can be anything, from section, lemma, theorem, etc.) in the Stacks project, you can <a href='" . href("tag") . "'>look up the tag's page</a>.</p>";
     $value .= "<h2><a href='" . href("tags") . "'>Referencing the Stacks project</a></h2>";
     $value .= "<p>Items (sections, lemmas, theorems, etc.) in the Stacks project are referenced by their tag. See the <a href='" . href("tags") . "'>tags explained page</a> to learn more about tags and how to reference them in a LaTeX document.</p>";
     $value .= "<h2>Leaving comments</h2>";
     $value .= "<p>You can leave comments on each and every tag's page. If you wish to stay updated on the comments, there is both a <a href='" . href("recent-comments") . "'>page containing recent comments</a> and an <a href='" . href("recent-comments.xml") . "' class='rss'>RSS feed</a> available.</p>";
     // TODO recent-comments.xml doesn't exist yet
     $value .= "<h2>Recent changes to the Stacks project</h2>";
     $value .= "<p>The Stacks project is hosted at GitHub, so you can <a href='https://github.com/stacks/stacks-project/commits/master'>browse the complete history</a> there.</p>";
     $value .= "<h2>License</h2>";
     $value .= "This project is licensed under the <a href='https://github.com/stacks/stacks-project/blob/master/COPYING'>GNU Free Documentation License</a>.";
     return $value;
 }
Пример #10
0
 public function doEdit()
 {
     $data['describe_info'] = doSafe($_POST['describe_info']);
     $data['nav'] = intval($_POST['nav']);
     if (empty($data['describe_info'])) {
         href('请填写完整的信息');
     }
     if ($this->id === 0) {
         //新增标签
         $res = $this->tag->addTag($data);
         if ($res) {
             href('新增标签成功', 2);
         } else {
             href('新增标签失败');
         }
     } else {
         //修改标签
         $res = $this->tag->chengeTagByTagId($this->id, $data);
         if ($res) {
             href('修改标签成功', 2);
         } else {
             href('修改标签失败');
         }
     }
 }
Пример #11
0
 public function process()
 {
     $http_host = $_SERVER['HTTP_HOST'];
     if ($http_host == 'localhost:8080') {
         $http_host = 'localhost';
     }
     $host_name = 'http://' . $http_host;
     $actual_url = str_replace($host_name, '', APPLICATION_ROOT);
     $actual_url = str_replace($actual_url, '', $_SERVER['REQUEST_URI']);
     $size = $this->getP3();
     if (!$size) {
         location('/error/base/' . urlencode('The url was invalid'));
     }
     $size_ex = explode('x', $size);
     $height = isset($size_ex[0]) ? $size_ex[0] : '100';
     $width = isset($size_ex[1]) ? $size_ex[1] : '100';
     $image_path = str_replace('/images/process/' . $size, '', $actual_url);
     $full_image_path = 'http://' . $http_host . $image_path;
     $headers = get_headers($full_image_path);
     foreach ($headers as $header) {
         if (strpos($header, 'Content-Type') !== false) {
             header($header);
         }
     }
     $new_url = 'http://' . $http_host . href('/framework/external/timthumb/timthumb.php');
     $new_url .= '?src=' . $image_path;
     $new_url .= '&h=' . $height;
     $new_url .= '&w=' . $width;
     echo file_get_contents($new_url);
 }
Пример #12
0
 public function getMain()
 {
     $value = "";
     $value .= "<h2>The tag system</h2>";
     $value .= "<p>Each tag refers to a unique item (section, lemma, theorem, etc.) in order for this project to be referenceable. These tags don't change even if the item moves within the text.";
     $value .= "<h2>How to use it?</h2>";
     $value .= "<p>To find the tag for an item, hover/click on the item in the <a href='download/book.pdf'>pdf file</a> or find the item in the tree view starting at <a href='" . href("chapter/1") . "'>Chapter 1</a>. See below for LaTeX instructions on how to reference a tag.";
     $value .= "<p>To find an item using a tag, <a href='" . href('tag') . "'>search for the tag's page</a>. The tag's page contains the location for the item referenced by the tag. It also contains its LaTeX code and a section for leaving comments.";
     $value .= "<h2>More information</h2>";
     $value .= "<p>The tag system provides stable references to definitions, lemmas, propositions, theorems, remarks, examples, exercises, situations and even equations, sections and items. As the project grows, each of these gets a tag which will always point to the same mathematical result. The place of the lemma in the document may change, the lemma may be moved to a different chapter, but its tag always keeps pointing to it.</p>";
     $value .= "<p>If it ever turns out that a lemma, theorem, etc. was wrong then we may remove it from the project. However, we will keep the tag, and there will be an explanation for its disappearance (in the file tags mentioned below).";
     $value .= "<h2 id='reference'>How to reference tags</h2>";
     $value .= "<p>In your BibTeX file put";
     $value .= "<pre><code>@misc{stacks-project,\n";
     $value .= "  shorthand    = {Stacks},\n";
     $value .= "  author       = {The {Stacks Project Authors}},\n";
     $value .= "  title        = {\\itshape Stacks Project},\n";
     $value .= "  howpublished = {\\url{http://stacks.math.columbia.edu}},\n";
     $value .= "  year         = {" . date('Y') . "},\n";
     $value .= "}</code></pre>";
     $value .= "Then you can use the citation code we provide on each tag's page (below the preview) to <em>cite</em> and <em>link</em> the corresponding tag, for example by";
     $value .= "<pre><code>\\cite[\\href{http://stacks.math.columbia.edu/tag/0123}{Tag 0123}]{stacks-project}</code></pre>";
     $value .= "<p>This can be changed according to your tastes. In order to make the <code>\\url</code> and <code>\\href</code> commands to work, one should use the <a href='http://ctan.org/pkg/hyperref'><code>hyperref</code></a> package. Some options are provided on the lookup page for a tag.</p>";
     $value .= "<h2>Technical information</h2>";
     $value .= "<p>There is a file called <a href='https://github.com/stacks/stacks-project/blob/master/tags/tags'><var>tags</var></a> (in the <a href='https://github.com/stacks/stacks-project/tree/master/tags'>tags subdirectory</a> of the Stacks project) which has on each line the tag followed by an identifier. Example:";
     $value .= "<pre><code>01MB,constructions-lemma-proj-scheme</code></pre>";
     $value .= "<p>Here the tag is <var>01MB</var> and the identifier is <var>constructions-lemma-proj-scheme</var>. This means that the tag points to a lemma from the file <var>constructions.tex</var>. It currently has the label <var>lemma-proj-scheme</var>. If we ever change the lemma's  label, or move the lemma to a different file, then we will change the corresponding line in the file tags by changing the identifier correspondingly. But we will <strong>never change the tag</strong>.</p>";
     $value .= "<p>A tag is a four character string made up out of digits and capital letters. They are ordered lexicographically between <var>0000</var> and <var>ZZZZ</var> originally giving 1679616 possible tags. But as there might arise confusion from the similarities between <var>0</var> and <var>O</var> it was decided to stop using the letter <var>O</var>. The last tag using <var>O</var> is <a href='" . href('tag/04DO') . "'>tag <var>04DO</var></a>. Thus from <var>04DP</var> on there are only 35 values per position. The 302 tags assigned before this new guideline will remain, as tags are constant.";
     $value .= "<h2 id='stacks-epoch'>Stacks epoch</h2>";
     $value .= "<p>The first 3026 tags were introduced in the Stacks project on <a href='https://github.com/stacks/stacks-project/commit/fad2e125112d54e1b53a7e130ef141010f9d151d'>May 16, 2009</a>. New tags are assigned by the maintainer of the Stacks project every once in a while using a script. As the Stacks project is always under construction the available tags on the website, in the git repository, and the available results in the Stacks project can sometimes be a little bit out of sync.";
     return $value;
 }
Пример #13
0
 public function getMain()
 {
     $value = "";
     $value .= "<h2>About</h2>";
     $value .= "<p>The Stacks project started in 2005. The initial idea was for it to be a collaborative web-based project with the aim of writing an introductory text about algebraic stacks. Temporarily there was a mailing list and some discussion as to how to proceed. For example, there are issues with referencing such a document, how to distribute credit, who does what, and many more. Although we have definite ideas about most of these points we would like to take a more positive approach. Namely, to simply create something and solve problems and answer questions as they come up.</p>";
     $value .= "<hr>";
     $value .= "<p>We do want to answer a few basic questions that the casual visitor may have about this project:</p>";
     $value .= "<ol>";
     $value .= "<li>The Stacks project is no longer an introductory text, but aims to build up enough basic algebraic geometry as foundations for algebraic stacks. This implies a good deal of theory on commutative algebra, schemes, varieties, algebraic spaces, has to be developed en route.";
     $value .= "<li>The Stacks project has a maintainer (currently <a href='http://www.math.columbia.edu/~dejong/'>Aise Johan de Jong</a>) who accepts changes etc. proposed by contributors. Although everyone is encouraged to participate it is not a wiki.";
     $value .= "<li>The Stacks project is meant to be read online, and therefore we do not worry about length of the chapters, etc. Moreover, with hyperlinks it is possible to quickly browse through the chapters to find the lemmas, theorems, etc. that a given result depends on.";
     $value .= "</ol>";
     $value .= "<h2><a href='" . href("acknowledgements") . "'>Acknowledgements</a></h2>";
     $value .= "<p>We have a page <a href='" . href("acknowledgements") . "'>acknowledging support</a>.";
     $value .= "<h2>The Stacks project, its website, and tools</h2>";
     $value .= "<p>There are currently three open source repositories tracking development for the Stacks project and its website:</p>";
     $value .= "<ol>";
     $value .= "<li>The LaTeX files making up the Stacks project itself can be found <a href='https://github.com/stacks/stacks-project'>here</a>.";
     $value .= "<li>The website is being developed as a <a href='https://github.com/stacks/stacks-website'>separate project</a>. It is currently maintained by <a href='http://pbelmans.wordpress.com/'>Pieter Belmans</a>.";
     $value .= "<li>There is a <a href='https://github.com/stacks/stacks-tools'>repository</a> containing tools and infrastructure used by both the project and the website.";
     $value .= "</ol>";
     $value .= "<p>If you wish to start your own project, inspired by the Stacks project we hope the combination of these projects can serve as a starting point. If you have any questions about this, please do not hesitate to send an email to <a href='mailto:stacks.project@gmail.com'>stacks.project@gmail.com</a>.";
     $value .= "<h2><a href='" . href("api") . "'>API</a></h2>";
     $value .= "<p>You can query the Stacks project through an <a href='" . href("api") . "'><abbr title='Application Programming Interface'>API</abbr></a>.";
     return $value;
 }
Пример #14
0
function plugin_list($message = '')
{
    pagetop(gTxt('edit_plugins'), $message);
    echo n . n . startTable('edit') . tr(tda(plugin_form(), ' colspan="8" style="height: 30px; border: none;"')) . endTable();
    extract(gpsa(array('sort', 'dir')));
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
        $sort = 'name';
    }
    $sort_sql = $sort . ' ' . $dir;
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $rs = safe_rows_start('name, status, author, author_uri, version, description, length(help) as help, abs(strcmp(md5(code),code_md5)) as modified, load_order, flags', 'txp_plugin', '1 order by ' . $sort_sql);
    if ($rs and numRows($rs) > 0) {
        echo '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list') . tr(column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', 'name' == $sort ? $dir : '') . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', 'author' == $sort ? $dir : '') . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', 'version' == $sort ? $dir : '') . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', 'modified' == $sort ? $dir : '') . hCell(gTxt('description')) . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', 'status' == $sort ? $dir : '') . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', 'load_order' == $sort ? $dir : '') . hCell(gTxt('manage'), '', ' class="manage"') . hCell());
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = htmlspecialchars($value);
            }
            // Fix up the description for clean cases
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            $help = !empty($help) ? n . t . '<li><a href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . urlencode($name) . '">' . gTxt('help') . '</a></li>' : '';
            $plugin_prefs = $flags & PLUGIN_HAS_PREFS && $status ? n . t . '<li><a href="?event=plugin_prefs.' . urlencode($name) . '">' . gTxt('plugin_prefs') . '</a></li>' : '';
            echo tr(n . td($name) . td(href($author, $author_uri)) . td($version, 10) . td($modified ? gTxt('yes') : '') . td($description, 260) . td(status_link($status, $name, yes_no($status)), 30) . td($load_order) . td(n . '<ul class="plugin_manage">' . $help . n . t . '<li>' . eLink('plugin', 'plugin_edit', 'name', $name, gTxt('edit')) . '</li>' . $plugin_prefs . n . '</ul>') . td(fInput('checkbox', 'selected[]', $name), 30));
            unset($name, $page, $deletelink);
        }
        echo tr(tda(select_buttons() . plugin_multiedit_form('', $sort, $dir, '', ''), ' colspan="10" style="text-align: right; border: none;"')) . n . endTable() . n . '</form>';
    }
}
Пример #15
0
/**
 * Renders and outputs a login form.
 *
 * This function outputs a full HTML document,
 * including &lt;head&gt; and footer.
 *
 * @param string|array $message The activity message
 */
function doLoginForm($message)
{
    global $textarray_script, $event, $step;
    include txpath . '/lib/txplib_head.php';
    $event = 'login';
    if (gps('logout')) {
        $step = 'logout';
    } elseif (gps('reset')) {
        $step = 'reset';
    }
    pagetop(gTxt('login'), $message);
    $stay = (cs('txp_login') and !gps('logout') ? 1 : 0);
    $reset = gps('reset');
    $name = join(',', array_slice(explode(',', cs('txp_login')), 0, -1));
    $out = array();
    if ($reset) {
        $out[] = hed(gTxt('password_reset'), 2, array('id' => 'txp-login-heading')) . graf(n . span(tag(gTxt('name'), 'label', array('for' => 'login_name')), array('class' => 'txp-label')) . n . span(fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), array('class' => 'txp-value')), ' class="login-name"') . graf(fInput('submit', '', gTxt('password_reset_button'), 'publish') . n) . graf(href(gTxt('back_to_login'), 'index.php'), array('class' => 'login-return')) . hInput('p_reset', 1);
    } else {
        $out[] = hed(gTxt('login_to_textpattern'), 2, array('id' => 'txp-login-heading')) . graf(n . span(tag(gTxt('name'), 'label', array('for' => 'login_name')), array('class' => 'txp-label')) . n . span(fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), array('class' => 'txp-value')), array('class' => 'login-name')) . graf(n . span(tag(gTxt('password'), 'label', array('for' => 'login_password')), array('class' => 'txp-label')) . n . span(fInput('password', 'p_password', '', '', '', '', INPUT_REGULAR, '', 'login_password'), array('class' => 'txp-value')), array('class' => 'login-password')) . graf(checkbox('stay', 1, $stay, '', 'login_stay') . n . tag(gTxt('stay_logged_in'), 'label', array('for' => 'login_stay')) . popHelp('remember_login') . n, array('class' => 'login-stay')) . graf(fInput('submit', '', gTxt('log_in_button'), 'publish') . n) . graf(href(gTxt('password_forgotten'), '?reset=1'), array('class' => 'login-forgot'));
        if (gps('event')) {
            $out[] = eInput(gps('event'));
        }
    }
    echo form(tag(join('', $out), 'section', array('role' => 'region', 'class' => 'txp-login', 'aria-labelledby' => 'txp-login-heading')), '', '', 'post', '', '', 'login_form') . script_js('textpattern.textarray = ' . json_encode($textarray_script)) . n . '</main><!-- /txp-body -->' . n . '</body>' . n . '</html>';
    exit(0);
}
Пример #16
0
function plugin_list($message = '')
{
    global $event;
    pagetop(gTxt('tab_plugins'), $message);
    echo '<h1 class="txp-heading">' . gTxt('tab_plugins') . '</h1>';
    echo '<div id="' . $event . '_control" class="txp-control-panel">';
    echo n . plugin_form() . n . '</div>';
    extract(gpsa(array('sort', 'dir')));
    if ($sort === '') {
        $sort = get_pref('plugin_sort_column', 'name');
    }
    if ($dir === '') {
        $dir = get_pref('plugin_sort_dir', 'asc');
    }
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
        $sort = 'name';
    }
    $sort_sql = $sort . ' ' . $dir;
    set_pref('plugin_sort_column', $sort, 'plugin', 2, '', 0, PREF_PRIVATE);
    set_pref('plugin_sort_dir', $dir, 'plugin', 2, '', 0, PREF_PRIVATE);
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $rs = safe_rows_start('name, status, author, author_uri, version, description, length(help) as help, abs(strcmp(md5(code),code_md5)) as modified, load_order, flags', 'txp_plugin', '1 order by ' . $sort_sql);
    if ($rs and numRows($rs) > 0) {
        echo n . '<div id="' . $event . '_container" class="txp-container">';
        echo '<form action="index.php" id="plugin_form" class="multi_edit_form" method="post" name="longform">' . n . '<div class="txp-listtables">' . n . startTable('', '', 'txp-list') . n . '<thead>' . tr(n . hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' title="' . gTxt('toggle_all_selected') . '" class="multi-edit"') . n . column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'name') . n . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', ('author' == $sort ? "{$dir} " : '') . 'author') . n . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', ('version' == $sort ? "{$dir} " : '') . 'version') . n . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', ('modified' == $sort ? "{$dir} " : '') . 'modified') . n . hCell(gTxt('description'), '', ' class="description"') . n . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', ('status' == $sort ? "{$dir} " : '') . 'status') . n . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', ('load_order' == $sort ? "{$dir} " : '') . 'load-order') . n . hCell(gTxt('manage'), '', ' class="manage actions"')) . n . '</thead>';
        echo '<tbody>';
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = txpspecialchars($value);
            }
            // Fix up the description for clean cases
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            $help = !empty($help) ? '<a class="plugin-help" href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . urlencode($name) . '">' . gTxt('help') . '</a>' : '';
            $plugin_prefs = $flags & PLUGIN_HAS_PREFS ? '<a class="plugin-prefs" href="?event=plugin_prefs.' . urlencode($name) . '">' . gTxt('plugin_prefs') . '</a>' : '';
            $manage = array();
            if ($help) {
                $manage[] = $help;
            }
            if ($plugin_prefs) {
                $manage[] = $plugin_prefs;
            }
            $manage_items = $manage ? join(tag(sp . '&#124;' . sp, 'span'), $manage) : '-';
            $edit_url = eLink('plugin', 'plugin_edit', 'name', $name, $name);
            echo tr(n . td(fInput('checkbox', 'selected[]', $name), '', 'multi-edit') . td($edit_url, '', 'name') . td(href($author, $author_uri, ' rel="external"'), '', 'author') . td($version, '', 'version') . td($modified ? '<span class="warning">' . gTxt('yes') . '</span>' : '', '', 'modified') . td($description, '', 'description') . td(status_link($status, $name, yes_no($status)), '', 'status') . td($load_order, '', 'load-order') . td($manage_items, '', 'manage'), $status ? ' class="active"' : '');
            unset($name, $page, $deletelink);
        }
        echo '</tbody>', n, endTable(), n, '</div>', n, plugin_multiedit_form('', $sort, $dir, '', ''), n, tInput(), n, '</form>', n, '</div>';
        // Show/hide "Options" link by setting the appropriate class on the plugins TR
        echo script_js(<<<EOS
textpattern.Relay.register('txpAsyncHref.success', function(event, data) {
\t\$(data['this']).closest('tr').toggleClass('active');
});
EOS
);
    }
}
Пример #17
0
function markdown($text)
{
    /*{{{*/
    $text = preg_replace('#([^[:alnum:]])(@([[:alnum:]-_]*))#', '$1[$2](http://twitter.com/$3)', $text);
    $text = preg_replace_callback('!#([[:alnum:]-_]+)!', function ($matches) {
        return sprintf('[%s](%s)', $matches[0], href('search?q=' . urlencode(strtolower($matches[0]))));
    }, $text);
    return (new ParsedownExtra())->text($text);
}
Пример #18
0
function getSimpleSearchForm($autofocus = true, $size = 20)
{
    $value = "";
    $value .= "<form class='simple' action='" . href("search") . "' method='get'>";
    $value .= "<label><span>Keywords:</span> <input type='text' name='keywords' " . ($autofocus ? "autofocus" : "") . " size='" . $size . "'></label>";
    $value .= "<input type='submit' value='search'>";
    $value .= "</form>";
    return $value;
}
Пример #19
0
 public static function isError($res)
 {
     if (!empty($res['errcode'])) {
         if ($res['errcode'] !== 0) {
             href('错误代码:' . $res['errcode'] . ' http://mp.weixin.qq.com/wiki/17/fa4e1434e57290788bde25603fa2fcbd.html点击查看错误');
             return true;
         }
     }
     return false;
 }
Пример #20
0
 public static function addMenu($data)
 {
     /*
              $data = array(
                'button'=> array(
                    array(
                        'type'=> 'click',
                        'name'=> '测试一',
                        'key'=> 'test1',
                    ),
                    array(
                        'name'=> '测试二',
                        'sub_button'=> array(
                            array(
                                'type'=> 'scancode_push',
                                'name'=> '扫码推事件',
                                'key'=> 'text2',
                            ),
                            array(
                                'type'=> 'scancode_push',
                                'name'=> '扫码推事件',
                                'key'=> 'text2',
                            ),
                        ),
                    ),
                    array(
                        'type'=> 'click',
                        'name'=> '测试三',
                        'key'=> 'test1',
                    ),
                ),
            );
     */
     if (count($data['button']) > 3 || count($data['button']) < 1) {
         href('主菜单不符合规定');
         exit;
     }
     foreach ($data['button'] as $key => $v) {
         if (isset($data['button'][$key]['sub_button'])) {
             if (count($data['button'][$key]['sub_button']) > 3) {
                 href('第' . $key + 1 . '个主菜单不符合规定');
                 exit;
             }
         }
     }
     $accessToken = AccessToken::getAccessToken();
     $url = ' https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $accessToken;
     $res = Curl::httpGet($url, $data);
     if ($res['errcode'] === 0) {
         href('添加菜单成功');
     } else {
         href('错误代码:' . $res['errcode'] . '点击http://mp.weixin.qq.com/wiki/10/6380dc743053a91c544ffd2b7c959166.html 查看错误信息');
     }
 }
 public function getSidebar()
 {
     $output = "";
     $output .= "<h2>Supporting institutions</h2>";
     $output .= "<div style='text-align: center'>";
     $output .= "<a href='http://simonsfoundation.org'><img style='margin-bottom: 30px; margin-top: 10px' width='180' src='" . href("images/logos/simons.png") . "'></a>";
     $output .= "<a href='http://columbia.edu'><img style='margin-bottom: 30px' src='" . href("images/logos/columbia.jpg") . "'></a>";
     $output .= "<a href='http://nsf.gov'><img width='180' src='" . href("images/logos/nsf.gif") . "'></a>";
     $output .= "</div>";
     return $output;
 }
Пример #22
0
 public static function setImage($file, $kf_account)
 {
     if (!file_exists($file)) {
         href('文件不存在');
         return false;
     }
     $url = 'http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=' . AccessToken::getAccessToken() . '&kf_account=' . $kf_account;
     $data = array('filename' => $file);
     $data = array("media" => "@" . $file, 'form-data' => $data);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res;
 }
Пример #23
0
 public function getMain()
 {
     $value = "";
     $value .= "<h2>Look for a tag</h2>";
     $value .= "<p>Look for a tag, if you have its 4-symbol code</p>";
     $value .= printTagLookup();
     $value .= "<p>For more information we refer to the <a href='" . href('tags') . "'>tags explained</a> page.";
     $value .= "<h2><a href='" . href("search") . "'>Search</a></h2>";
     $value .= "<p>Are you instead looking for the search functionality?</p>";
     $value .= getSimpleSearchForm(false);
     return $value;
 }
Пример #24
0
 public function getMain()
 {
     $output = "";
     $output .= "<h2>Inactive tag: <var>" . $this->tag . "</var></h2>";
     $output .= "<p>The tag you requested did at some point in time belong to the Stacks project, but it was removed. You might be able to find a clue in the <a href='https://github.com/stacks/stacks-project/blob/master/tags/tags'>tags file</a>.</p>";
     $output .= "<h2>Look for a tag</h2>";
     $output .= printTagLookup();
     $output .= "<p>For more information we refer to the <a href='" . href('tags') . "'>tags explained</a> page.";
     $output .= "<h2><a href='" . href("search") . "'>Search</a></h2>";
     $output .= "<p>Are you instead looking for the search functionality?</p>";
     $output .= getSimpleSearchForm(false);
     return $output;
 }
Пример #25
0
 public function doEdit()
 {
     $id = intval($_GET['id']);
     $comment = trim($_POST['comment']);
     if (empty($id) || empty($comment)) {
         href('请填写完整信息');
     }
     if ($this->comment->updateComment($id, $comment)) {
         href('修改成功', 2);
     } else {
         href('修改失败');
     }
 }
Пример #26
0
 public function getMain()
 {
     $output = "";
     $output .= "<h2>Invalid tag: <var>" . htmlentities($this->tag) . "</var></h2>";
     $output .= "<p>This is not a well-formed tag. Tags are 4 symbols long and consist of letters and digits.</p>";
     $output .= "<h2>Look for a tag</h2>";
     $output .= printTagLookup();
     $output .= "<p>For more information we refer to the <a href='" . href('tags') . "'>tags explained</a> page.";
     $output .= "<h2><a href='" . href("search") . "'>Search</a></h2>";
     $output .= "<p>Are you instead looking for the search functionality?</p>";
     $output .= getSimpleSearchForm(false);
     return $output;
 }
Пример #27
0
 public function getMain()
 {
     $output = "";
     $output .= "<h2>Missing tag: <var>" . $this->tag . "</var></h2>";
     $lastTag = getLastTag();
     $output .= "<p>The tag you requested does not exist. This probably means that we haven't gotten that far yet. The last tag currently in the database is <a href='" . href("tag/" . $lastTag) . "'>tag <var>" . $lastTag . "</var></a>.";
     $output .= "<h2>Look for a tag</h2>";
     $output .= printTagLookup();
     $output .= "<p>For more information we refer to the <a href='" . href('tags') . "'>tags explained</a> page.";
     $output .= "<h2><a href='" . href("search") . "'>Search</a></h2>";
     $output .= "<p>Are you instead looking for the search functionality?</p>";
     $output .= getSimpleSearchForm(false);
     return $output;
 }
Пример #28
0
function get_hierarchy($array, $count, $x = 0)
{
    if ($array[$x]) {
        $html = '<ul>';
        foreach ($array[$x] as $key => $value) {
            $html .= '<li>';
            $html .= '<a href="' . href(explode(",", $array[$x][$key][1])) . '">' . $array[$x][$key][0] . '</a>';
            $html .= get_hierarchy($array, $count, $key);
            $html .= '</li>';
        }
        $html .= '</ul>';
    }
    return $html;
}
Пример #29
0
 public static function addMedia($file, $type = 'image', $info = array())
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . AccessToken::getAccessToken();
     if (!file_exists($file)) {
         href('文件不存在');
         exit;
     }
     $data = array('filename' => $file);
     if ($type == 'video') {
         $description = array('title' => $info['title'], 'introduction' => $info['introduction']);
         $data = array("media" => "@" . $file, 'form-data' => $data, 'type' => $type, 'description' => $description);
     } else {
         $data = array("media" => "@" . $file, 'form-data' => $data, 'type' => $type);
     }
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res;
 }
Пример #30
0
 public static function getSearchForm($keywords = "", $options = array())
 {
     $output = "";
     $output .= "<form id='search' method='get' action='" . href('search') . "'>\n      <fieldset>\n        <legend>Query</legend>\n        <label for='keywords'>Keywords: <input type='text' id='keywords' size='35' name='keywords' value=\"" . $keywords . "\"></label>\n        <label><input type='submit' id='submit' value='Search' /></label>\n      </fieldset>\n\n      <fieldset>\n        <legend>Options</legend>\n        <p>Limit your search to include:<br>";
     if (!array_key_exists("limit", $options)) {
         $output .= "\n        <label for='limit-none'><input type='radio' value='all' name='limit' id='limit-none' checked='checked'> all tags</label><br>\n        <label for='limit-sections'><input type='radio' name='limit' value='sections' id='limit-sections'> only complete sections</label><br>\n        <label for='limit-statements'><input type='radio' name='limit' value='statements' id='limit-statements'> only statements, not the proofs</label>";
     } else {
         $output .= "\n        <label for='limit-none'><input type='radio' value='all' name='limit' id='limit-none'" . ($options["limit"] == "all" ? " checked='checked'" : "") . "> all tags</label><br>\n        <label for='limit-sections'><input type='radio' name='limit' value='sections' id='limit-sections'" . ($options["limit"] == "sections" ? " checked='checked'" : "") . "> only complete sections</label><br>\n        <label for='limit-statements'><input type='radio' name='limit' value='statements' id='limit-statements'" . ($options["limit"] == "statements" ? " checked='checked'" : "") . "> only statements, not the proofs</label>";
     }
     $output .= "<p>If a query matches both a tag and a parent tag, only display the child:<br>";
     if (!array_key_exists("exclude-duplicates", $options)) {
         $output .= "<label for='exclude-duplicates'><input type='checkbox' name='exclude-duplicates' id='exclude-duplicates'> remove duplicates</label>";
     } else {
         $output .= "<label for='exclude-duplicates'><input type='checkbox' name='exclude-duplicates' id='exclude-duplicates' checked='checked'> remove duplicates</label>";
     }
     $output .= "</fieldset></form>";
     return $output;
 }