close

Plugin Directory

Changeset 489029


Ignore:
Timestamp:
01/12/2012 09:28:18 PM (14 years ago)
Author:
divinenephron
Message:

Added a lot of documentation.

Location:
latex-everything/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • latex-everything/trunk/class-latex-document.php

    r489028 r489029  
    66
    77/*
    8  * get_posts
    9  * typeset_all_files
    10  * get_template
    11  * get_title
    12  * get_name
    13  * get_parent_post_id
    148 */
    159
     
    4337 *      Return: String containing the pdf url.
    4438 *
     39 * Methods that must be defined by LE_Latex_Document subclasses
     40 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     41 *
     42 * get_posts()
     43 *      Return an array of post objects to be typset for the document.
     44 *
     45 * typeset_all_files()
     46 *      Produce a single pdf file from the contents of $this->latex_files.
     47 *      Return a string containing its path.
     48 *
     49 * get_template()
     50 *      Return a string containing the path to the template to be used by
     51 *      the document.
     52 *
     53 * get_title()
     54 *      Return the title for the attachment (show on the attachment page and
     55 *      on the admin screen).
     56 *
     57 * get_name()
     58 *      Return the name of the attachment. This should be a slug. Used as the
     59 *      PDF file's name.
     60 *
     61 * get_parent_post_id()
     62 *      (optional) Return the id of the parent of the attachment, if this
     63 *      attachment has one.
    4564 */
     65
    4666class LE_Latex_Document {
    4767
     
    274294        return wp_get_attachment_url( $this->get_attachment_id() );
    275295    }
     296
     297    function get_parent_post_id() {
     298        return 0;
     299    }
    276300}
    277301
     
    329353        return 0;
    330354    }
    331 
    332     function get_parent_post_id() {
    333         return 0;
    334     }
    335355}
    336356
  • latex-everything/trunk/default-latex-template.php

    r489028 r489029  
    66\setlength{\parindent}{0ex}
    77
     8% Note that there isn't a loop, just the_post()
     9% This is because Latex isn't designed to typset multiple articles at once.
     10% This template typesets a single post, then multiple PDFs will be stitched
     11% together by the plugin, so please don't try to make The Loop.
    812<?php the_post() ?>
    913
     14% Note I've used the lt() function.
     15% The same job is done by latex_text() and get_latex_text() (which returns
     16% a string rather than echoing it).
     17% This function performs substitutions to make text pretty and suitable for
     18% inclusion in macro arguments. If you don't wrap your output in it you
     19% might get errors.
    1020\date{<?php lt( get_the_date() ) ?>}
    1121\title{<?php lt( get_the_title() ) ?>}
     
    1626\maketitle
    1727
     28% Note the use of the h2l() function.
     29% The same job is done by html_to_latex() and get_html_to_latex() (which
     30% returns a string rather than echoing it).
     31% This converts html into Latex equivalents, and can be found in
     32% html-to-latex.php.
    1833<?php h2l( apply_filters( 'the_content', get_the_content() ) ) ?>
    1934
     35% I've only tested this templating with string output functions such as
     36% those shown above. I doubt other functions, most notably the is_something()
     37% functions will work correctly.
    2038\end{document}
  • latex-everything/trunk/latex-everything.php

    r489028 r489029  
    22/*
    33   Plugin Name: Latex Everything
    4    Plugin URI:
    5    Version: 0.1
     4   Plugin URI: http://wordpress.org/extend/plugins/latex-everything
     5   Version: 1.0
    66   Author: Divinenephron (Devon Buchanan)
    77   Author URI: http://divinenephron.co.uk
    8    Description:
    9    License: GPL
    10  */
    11 
    12 // TODO: Make documentation of API and install process.
     8   Description: Produce PDF documents of everything on your site with Latex.
     9   License: GPLv3
     10 */
    1311
    1412global $latex_everything;
    1513$latex_everything = new Latex_Everything;
    1614
     15include('latex-single-posts.php');
    1716include('latex-post-types.php');
    18 include('latex-single-posts.php');
    1917include('latex-terms.php');
     18
     19/* Latex_Everything
     20 * - - - - - - - -
     21 *
     22 * This class decides when to make documents and tells us where they are.
     23 *
     24 * LE_Latex_<type>_Controller
     25 * - - - - - - - - - - - -
     26 * These classes are used by Latex_Everything to decide which documents
     27 * need to be created. There is one for each document type (post_type,
     28 * term, single_post).
     29 *
     30 * They are added to Latex_Everything with a function call, e.g.
     31 *
     32 *      global $latex_everything;
     33 *      $latex_post_type_controller = new LE_Latex_Post_Type_Controller();
     34 *      $latex_everything->add_controller( 'post_type', &$latex_post_type_controller );
     35 *
     36 * These controllers need to define certain methods to work
     37 *
     38 * documents_for_post( $post_id )
     39 *      Return an array of new documents. Latex_Everything will call generate() with them.
     40 *
     41 * get_document( arg1, [$arg2] )
     42 *      Return a single document object.
     43 *
     44 * get_settings()
     45 *      Return an array containing the settings this controller cares about. It is in the form:
     46 *      array( [0] => array( 'name' => "le_post_type_{$post_type}",
     47 *                           'title' => "All {$post_type_obj->labels->name}" ),
     48 *             [1] => ... );
     49 *      Each 'name' index corresponds to a document the controller might generate (e.g. a document
     50 *      containing a single post, all posts with a specific tag, or all posts of a custom type).
     51 *      The user is able to activate or dactivate their generation with this setting, which should
     52 *      be checked with in documents_for_post(). The 'title' index is a human-readable description.
     53 */
    2054
    2155/* When the plugin is activated, create cron jobs to create the desired pdf.
  • latex-everything/trunk/uninstall.php

    r489027 r489029  
    22if( !defined( 'ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') )
    33    exit();
    4 
    5 // Remove every generated pdf
    6 $args = array( 'post_type' => 'attachment',
    7            'numberposts' => -1,
    8            'meta_key' => '_a2l_is_latex',
    9            'meta_value' => 1,
    10            );
    11 $attachments = get_posts($args);
    12 foreach ($attachments as $attachment)
    13     wp_delete_attachment( $attachment->ID );
    144
    155/* Remove the options
Note: See TracChangeset for help on using the changeset viewer.