Advertisement
PaulLT

Untitled

Dec 16th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.60 KB | None | 0 0
  1. <?php defined('BASEPATH') OR exit('Tiesioginis scripto vykdymas negalimas');
  2. /**
  3.  * Kalendoriaus pluginas
  4.  *
  5.  * @package PyroCMS
  6.  * @author  Paulius Valiunas
  7.  *
  8.  */
  9. class Plugin_Calendar extends Plugin{
  10.     public $version = '1.0.0';
  11.  
  12.     public $name = array(
  13.         'en'    => 'Calendar',
  14.         'lt'    => 'Kalendorius'
  15.     );
  16.  
  17.     public $description = array(
  18.         'en'    => 'Event Calendar',
  19.         'lt'    => 'Įvykių kalendorius'
  20.     );
  21.    
  22.     public function _self_doc(){
  23.         $info = array(
  24.             'menesis' => array(
  25.                 'description' => array(// a single sentence to explain the purpose of this method
  26.                     'en' => 'Prints a month calendar',
  27.                     'lt' => 'Išspausdina mėnesio kalendorių'
  28.                 ),
  29.                 'single' => true,// will it work as a single tag?
  30.                 'double' => false,// how about as a double tag?
  31.                 'variables' => '',// list all variables available inside the double tag. Separate them|like|this
  32.                 'attributes' => array(
  33.                     'metai' => array(// this is the name="World" attribute
  34.                         'type' => 'number',// Can be: slug, number, flag, text, array, any.
  35.                         'flags' => '',// flags are predefined values like asc|desc|random.
  36.                         'default' => date('Y'),// this attribute defaults to this if no value is given
  37.                         'required' => false,// is this attribute required?
  38.                     ),
  39.                     'menuo' => array(// this is the name="World" attribute
  40.                         'type' => 'number',// Can be: slug, number, flag, text, array, any.
  41.                         'flags' => '',// flags are predefined values like asc|desc|random.
  42.                         'default' => date('m'),// this attribute defaults to this if no value is given
  43.                         'required' => false,// is this attribute required?
  44.                     ),
  45.                 ),
  46.             ),
  47.         );
  48.    
  49.         return $info;
  50.     }
  51.     /**
  52.      * Menesis
  53.      *
  54.      * Usage:
  55.      * {{ kalendorius:menesis }}
  56.      *
  57.      * @return string
  58.      */
  59.     function menesis(){
  60.         $metai = $this->attribute('metai', date('Y'));
  61.         $menuo = $this->attribute('menuo', date('m'));
  62.         $dienusk = date('t');
  63.         $diena = date('d');
  64.         $savd1 = date('N', strtotime($metai . '-' . $menuo . '-01'));
  65.         for($i=1; $i<=$dienusk; $i++){
  66.             $savd = ($savd1 + $i - 1) % 7;
  67.             if($i>1 && $savd == 1) $tekstas = $tekstas . '<br />';
  68.             $tekstas = $tekstas . $this->diena(strtotime($metai . '-' . $menuo . '-' . $i));
  69.         }
  70.     }
  71.    
  72.     function diena($laikas){
  73.         $ivykiai = $this->conn->query('SELECT * FROM `ivykiai` WHERE `data`=`' . $laikas . '`');
  74.         $tekstas = '<div class="diena">';
  75.         foreach($ivykiai as $a){
  76.             $tekstas = $tekstas . '<div class="ivykis">';
  77.             // parasyti pavadinima ar kazka pns
  78.             $tekstas = $tekstas . '</div>';
  79.         }
  80.         $tekstas = $tekstas . '</div>';
  81.         return $tekstas;
  82.     }
  83. }
  84.  
  85. /* End of file kalendorius.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement