Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('BASEPATH') OR exit('Tiesioginis scripto vykdymas negalimas');
- /**
- * Kalendoriaus pluginas
- *
- * @package PyroCMS
- * @author Paulius Valiunas
- *
- */
- class Plugin_Calendar extends Plugin{
- public $version = '1.0.0';
- public $name = array(
- 'en' => 'Calendar',
- 'lt' => 'Kalendorius'
- );
- public $description = array(
- 'en' => 'Event Calendar',
- 'lt' => 'Įvykių kalendorius'
- );
- public function _self_doc(){
- $info = array(
- 'menesis' => array(
- 'description' => array(// a single sentence to explain the purpose of this method
- 'en' => 'Prints a month calendar',
- 'lt' => 'Išspausdina mėnesio kalendorių'
- ),
- 'single' => true,// will it work as a single tag?
- 'double' => false,// how about as a double tag?
- 'variables' => '',// list all variables available inside the double tag. Separate them|like|this
- 'attributes' => array(
- 'metai' => array(// this is the name="World" attribute
- 'type' => 'number',// Can be: slug, number, flag, text, array, any.
- 'flags' => '',// flags are predefined values like asc|desc|random.
- 'default' => date('Y'),// this attribute defaults to this if no value is given
- 'required' => false,// is this attribute required?
- ),
- 'menuo' => array(// this is the name="World" attribute
- 'type' => 'number',// Can be: slug, number, flag, text, array, any.
- 'flags' => '',// flags are predefined values like asc|desc|random.
- 'default' => date('m'),// this attribute defaults to this if no value is given
- 'required' => false,// is this attribute required?
- ),
- ),
- ),
- );
- return $info;
- }
- /**
- * Menesis
- *
- * Usage:
- * {{ kalendorius:menesis }}
- *
- * @return string
- */
- function menesis(){
- $metai = $this->attribute('metai', date('Y'));
- $menuo = $this->attribute('menuo', date('m'));
- $dienusk = date('t');
- $diena = date('d');
- $savd1 = date('N', strtotime($metai . '-' . $menuo . '-01'));
- for($i=1; $i<=$dienusk; $i++){
- $savd = ($savd1 + $i - 1) % 7;
- if($i>1 && $savd == 1) $tekstas = $tekstas . '<br />';
- $tekstas = $tekstas . $this->diena(strtotime($metai . '-' . $menuo . '-' . $i));
- }
- }
- function diena($laikas){
- $ivykiai = $this->conn->query('SELECT * FROM `ivykiai` WHERE `data`=`' . $laikas . '`');
- $tekstas = '<div class="diena">';
- foreach($ivykiai as $a){
- $tekstas = $tekstas . '<div class="ivykis">';
- // parasyti pavadinima ar kazka pns
- $tekstas = $tekstas . '</div>';
- }
- $tekstas = $tekstas . '</div>';
- return $tekstas;
- }
- }
- /* End of file kalendorius.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement