Changeset 489029
- Timestamp:
- 01/12/2012 09:28:18 PM (14 years ago)
- Location:
- latex-everything/trunk
- Files:
-
- 1 added
- 4 edited
-
class-latex-document.php (modified) (4 diffs)
-
default-latex-template.php (modified) (2 diffs)
-
latex-everything.php (modified) (1 diff)
-
readme.txt (added)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
latex-everything/trunk/class-latex-document.php
r489028 r489029 6 6 7 7 /* 8 * get_posts9 * typeset_all_files10 * get_template11 * get_title12 * get_name13 * get_parent_post_id14 8 */ 15 9 … … 43 37 * Return: String containing the pdf url. 44 38 * 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. 45 64 */ 65 46 66 class LE_Latex_Document { 47 67 … … 274 294 return wp_get_attachment_url( $this->get_attachment_id() ); 275 295 } 296 297 function get_parent_post_id() { 298 return 0; 299 } 276 300 } 277 301 … … 329 353 return 0; 330 354 } 331 332 function get_parent_post_id() {333 return 0;334 }335 355 } 336 356 -
latex-everything/trunk/default-latex-template.php
r489028 r489029 6 6 \setlength{\parindent}{0ex} 7 7 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. 8 12 <?php the_post() ?> 9 13 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. 10 20 \date{<?php lt( get_the_date() ) ?>} 11 21 \title{<?php lt( get_the_title() ) ?>} … … 16 26 \maketitle 17 27 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. 18 33 <?php h2l( apply_filters( 'the_content', get_the_content() ) ) ?> 19 34 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. 20 38 \end{document} -
latex-everything/trunk/latex-everything.php
r489028 r489029 2 2 /* 3 3 Plugin Name: Latex Everything 4 Plugin URI: 5 Version: 0.14 Plugin URI: http://wordpress.org/extend/plugins/latex-everything 5 Version: 1.0 6 6 Author: Divinenephron (Devon Buchanan) 7 7 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 */ 13 11 14 12 global $latex_everything; 15 13 $latex_everything = new Latex_Everything; 16 14 15 include('latex-single-posts.php'); 17 16 include('latex-post-types.php'); 18 include('latex-single-posts.php');19 17 include('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 */ 20 54 21 55 /* When the plugin is activated, create cron jobs to create the desired pdf. -
latex-everything/trunk/uninstall.php
r489027 r489029 2 2 if( !defined( 'ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) 3 3 exit(); 4 5 // Remove every generated pdf6 $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 );14 4 15 5 /* Remove the options
Note: See TracChangeset
for help on using the changeset viewer.