diff --git a/classes/DcaHelper.php b/classes/DcaHelper.php new file mode 100644 index 0000000..830303c --- /dev/null +++ b/classes/DcaHelper.php @@ -0,0 +1,113 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +/** + * Class DcaHelper + */ +class DcaHelper extends \Backend +{ + + /** + * Constructor + */ + public function __construct() { + parent::__construct(); + } + + /** + * Return all navigation templates as array + * @param DataContainer + * @return array + */ + public function getRateItTemplates(\DataContainer $dc) + { + $intPid = $dc->activeRecord->pid; + + if ($this->Input->get('act') == 'overrideAll') + { + $intPid = $this->Input->get('id'); + } + + return $this->getTemplateGroup('rateit_', $intPid); + } + + /** + * Anlegen eines Datensatzes in der Tabelle tl_rateit_items, falls dieser noch nicht exisitiert. + * @param mixed + * @param object + * @return string + */ + public function insertOrUpdateRatingKey(\DC_Table $dc, $type, $ratingTitle) { + if ($dc->activeRecord->rateit_active || $dc->activeRecord->addRating) { + $actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ=?") + ->execute($dc->activeRecord->id, $type) + ->fetchAssoc(); + if (!is_array($actRecord)) { + $arrSet = array('rkey' => $dc->activeRecord->id, + 'tstamp' => time(), + 'typ' => $type, + 'createdat' => time(), + 'title'=> $ratingTitle, + 'active' => '1' + ); + $insertRecord = $this->Database->prepare("INSERT INTO tl_rateit_items %s") + ->set($arrSet) + ->execute() + ->insertId; + } else { + $this->Database->prepare("UPDATE tl_rateit_items SET active='1', title=? WHERE rkey=? and typ=?") + ->execute($ratingTitle, $dc->activeRecord->id, $type) + ->updatedId; + } + } else { + $this->Database->prepare("UPDATE tl_rateit_items SET active='' WHERE rkey=? and typ=?") + ->execute($dc->activeRecord->id, $typ) + ->updatedId; + + } + return true; + } + + /** + * Löschen eines Datensatzes aus der Tabelle tl_rateit_items. + * @param mixed + * @param object + * @return string + */ + public function deleteRatingKey(\DC_Table $dc, $type) + { + $this->Database->prepare("DELETE FROM tl_rateit_items WHERE rkey=? and typ=?") + ->execute($dc->activeRecord->id, $type); + return true; + } +} +?> \ No newline at end of file diff --git a/classes/RateItArticle.php b/classes/RateItArticle.php new file mode 100644 index 0000000..044abb0 --- /dev/null +++ b/classes/RateItArticle.php @@ -0,0 +1,274 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +class RateItArticle extends RateItFrontend { + + /** + * Initialize the controller + */ + public function __construct() { + parent::__construct(); + } + + public function parseTemplateRateIt($objTemplate) { + if ($objTemplate->type == 'article') { + $objTemplate = $this->doArticle($objTemplate); + } else if ($objTemplate->type == 'articleList') { + $objTemplate = $this->doArticleList($objTemplate); + } else if ($objTemplate->type == 'gallery') { + $objTemplate = $this->doGallery($objTemplate); + } + return $objTemplate; + } + + private function doArticle($objTemplate) { + $arrArticle = $this->Database->prepare('SELECT * FROM tl_article WHERE ID=?') + ->limit(1) + ->execute($objTemplate->id) + ->fetchAssoc(); + + if ($arrArticle['addRating']) { + if ($objTemplate->multiMode && $objTemplate->showTeaser) { + $objTemplate->setName('mod_'.$arrArticle['rateit_template'].'_teaser'); + } else { + $objTemplate->setName($arrArticle['rateit_template']); + } + + $ratingId = $arrArticle['id']; + $rating = $this->loadRating($ratingId, 'article'); + $stars = !$rating ? 0 : $this->percentToStars($rating['rating']); + $percent = round($rating['rating'], 0)."%"; + + $objTemplate->descriptionId = 'rateItRating-'.$ratingId.'-description'; + $objTemplate->description = $this->getStarMessage($rating); + $objTemplate->rateItID = 'rateItRating-'.$ratingId.'-article-'.$stars.'_'.$this->intStars; + $objTemplate->rateit_class = 'rateItRating'; + $objTemplate->itemreviewed = $rating['title']; + $objTemplate->actRating = $this->percentToStars($rating['rating']); + $objTemplate->maxRating = $this->intStars; + $objTemplate->votes = $rating[totalRatings]; + + if ($this->strTextPosition == "before") { + $objTemplate->showBefore = true; + } + else if ($this->strTextPosition == "after") { + $objTemplate->showAfter = true; + } + + if ($arrArticle['rateit_position'] == 'before') { + $objTemplate->rateit_rating_before = true; + } else if ($arrArticle['rateit_position'] == 'after') { + $objTemplate->rateit_rating_after = true; + } + + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.css||static'; + switch ($GLOBALS['TL_CONFIG']['rating_type']) { + case 'hearts' : + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.css||static'; + break; + default: + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.css||static'; + } + } + + return $objTemplate; + } + + private function doArticleList($objTemplate) { + if ($objTemplate->rateit_active) { + $bolTemplateFixed = false; + $arrArticles = array(); + foreach ($objTemplate->articles as $article) { + $arrArticle = $this->Database->prepare('SELECT * FROM tl_article WHERE ID=?') + ->limit(1) + ->execute($article['articleId']) + ->fetchAssoc(); + + if ($arrArticle['addRating']) { + if (!$bolTemplateFixed) { + $objTemplate->setName($objTemplate->getName().'_rateit'); + $bolTemplateFixed = true; + } + + $ratingId = $arrArticle['id']; + $rating = $this->loadRating($ratingId, 'article'); + $stars = !$rating ? 0 : $this->percentToStars($rating['rating']); + $percent = round($rating['rating'], 0)."%"; + + $article['descriptionId'] = 'rateItRating-'.$ratingId.'-description'; + $article['description'] = $this->getStarMessage($rating); + $article['rateItID'] = 'rateItRating-'.$ratingId.'-article-'.$stars.'_'.$this->intStars; + $article['rateit_class'] = 'rateItRating'; + $article['itemreviewed'] = $rating['title']; + $article['actRating'] = $this->percentToStars($rating['rating']); + $article['maxRating'] = $this->intStars; + $article['votes'] = $rating[totalRatings]; + + if ($this->strTextPosition == "before") { + $article['showBefore'] = true; + } + else if ($this->strTextPosition == "after") { + $article['showAfter'] = true; + } + + if ($arrArticle['rateit_position'] == 'before') { + $article['rateit_rating_before'] = true; + } else if ($arrArticle['rateit_position'] == 'after') { + $article['rateit_rating_after'] = true; + } + + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.css||static'; + switch ($GLOBALS['TL_CONFIG']['rating_type']) { + case 'hearts' : + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.css||static'; + break; + default: + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.css||static'; + } + } + + $arrArticles[] = $article; + } + $objTemplate->articles = $arrArticles; + } + return $objTemplate; + } + + private function doGallery($objTemplate) { + $arrGallery = $this->Database->prepare('SELECT * FROM tl_content WHERE ID=?') + ->limit(1) + ->execute($objTemplate->id) + ->fetchAssoc(); + + if ($arrGallery['rateit_active']) { + $arrRating = array(); + + if (version_compare(VERSION, '3.2', '>=')) { + $objFiles = \FilesModel::findMultipleByUuids(deserialize($arrGallery['multiSRC'])); + } else { + $objFiles = \FilesModel::findMultipleByIds(deserialize($arrGallery['multiSRC'])); + } + + if ($objFiles !== null) { + // Get all images + while ($objFiles->next()) { + // Continue if the files has been processed or does not exist + if (isset($arrRating[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) { + continue; + } + + // Single files + if ($objFiles->type == 'file') { + $objFile = new \File($objFiles->path, true); + + if (!$objFile->isGdImage) { + continue; + } + + $this->addRatingForImage($arrRating, $arrGallery['id'], $objFile->id, $objFile->path); + } + // Folders + else { + if (version_compare(VERSION, '3.2', '>=')) { + $objSubfiles = \FilesModel::findByPid($objFiles->uuid); + } else { + $objSubfiles = \FilesModel::findByPid($objFiles->id); + } + + if ($objSubfiles === null) { + continue; + } + + while ($objSubfiles->next()) { + // Skip subfolders + if ($objSubfiles->type == 'folder') { + continue; + } + + $objFile = new \File($objSubfiles->path, true); + + if (!$objFile->isGdImage) { + continue; + } + + $this->addRatingForImage($arrRating, $arrGallery['id'], $objSubfiles->id, $objSubfiles->path); + } + } + } + } + + $objTemplate->arrRating = $arrRating; + + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.css||static'; + switch ($GLOBALS['TL_CONFIG']['rating_type']) { + case 'hearts' : + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.css||static'; + break; + default: + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.css||static'; + } + } + + return $objTemplate; + } + + private function addRatingForImage(&$arrRating, $galleryId, $picId, $picPath) { + $ratingId = $galleryId.'|'.$picId; + $rating = $this->loadRating($ratingId, 'galpic'); + $stars = !$rating ? 0 : $this->percentToStars($rating['rating']); + $percent = round($rating['rating'], 0)."%"; + + $arrRating[$picPath] = array(); + $arrRating[$picPath]['descriptionId'] = 'rateItRating-'.$ratingId.'-description'; + $arrRating[$picPath]['description'] = $this->getStarMessage($rating); + $arrRating[$picPath]['rateItID'] = 'rateItRating-'.$ratingId.'-galpic-'.$stars.'_'.$this->intStars; + $arrRating[$picPath]['rateit_class'] = 'rateItRating'; + $arrRating[$picPath]['itemreviewed'] = $rating['title']; + $arrRating[$picPath]['actRating'] = $this->percentToStars($rating['rating']); + $arrRating[$picPath]['maxRating'] = $this->intStars; + $arrRating[$picPath]['votes'] = $rating[totalRatings]; + + if ($this->strTextPosition == "before") { + $arrRating[$picPath]['showBefore'] = true; + } + else if ($this->strTextPosition == "after") { + $arrRating[$picPath]['showAfter'] = true; + } + } +} +?> \ No newline at end of file diff --git a/classes/RateItBackend.php b/classes/RateItBackend.php new file mode 100644 index 0000000..3f2886f --- /dev/null +++ b/classes/RateItBackend.php @@ -0,0 +1,110 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +class RateItBackend +{ + const path = 'system/modules/rateit/'; + + /** + * Get a css file. + * @param string $file The basename if the file (without extension). + * @return string The file path. + */ + public static function css($file) + { + return self::path.'public/css/'. $file.'.css'; + } // file + + /** + * Get a js file. + * @param string $file The basename if the file (without extension). + * @return string The file path. + */ + public static function js($file) + { + return self::path.'public/js/'. $file.'.js'; + } // file + + /** + * Get image url from the theme. + * @param string $file The basename if the image (without extension). + * @return string The image path. + */ + public static function image($file) + { + $url = self::path.'public/images/'; + if (is_file(TL_ROOT.'/'.$url.$file.'.png')) return $url.$file.'.png'; + if (is_file(TL_ROOT.'/'.$url.$file.'.gif')) return $url.$file.'.gif'; + return $url.'default.png'; + } // image + + /** + * Create a 'img' tag from theme icons. + * @param string $file The basename if the image (without extension). + * @param string $alt The 'alt' text. + * @param string $attributes Additional tag attributes. + * @return string The html code. + */ + public static function createImage($file, $alt='', $attributes='') + { + if ($alt=='') $alt = 'icon'; + $img = self::image($file); + $size = getimagesize(TL_ROOT.'/'.$img); + return ''; + } // createImage + + /** + * Create a list button (link button) + * @param string $file The basename if the image (without extension). + * @param string $link The URL of the link to create. + * @param string $text The alt/title text. + * @param string $confirm Optional confirmation text before redirecting to the link. + * @param boolean $popup Open the target in a new window. + * @return string The html code. + */ + public function createListButton($file, $link, $text, $confirm='', $popup=false) + { + $target = $popup ? ' target="_blank"' : ''; + $onclick = ($confirm!='') ? ' onclick="if(!confirm(\''.$confirm.'\'))return false"' : ''; + return ''.$this->createImage($file,$text).''; + } // createListButton + + public function createMainButton($file, $link, $text, $confirm='') + { + $onclick = ($confirm=='') + ? '' + : ' onclick="if(!confirm(\''.$confirm.'\'))return false"'; + return ''.$this->createImage($file,$text).' '.$text.''; + } // createMainButton +} // class RateItBackend + +?> diff --git a/classes/RateItBackendModule.php b/classes/RateItBackendModule.php new file mode 100644 index 0000000..578a865 --- /dev/null +++ b/classes/RateItBackendModule.php @@ -0,0 +1,801 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +class rateitBackendModule extends \BackendModule +{ + protected $strTemplate; + protected $actions = array(); + + protected $rateit; + + protected $tl_root; + protected $tl_files; + protected $languages; + + private $compiler; + private $action = ''; + private $parameter = ''; + + private $arrExportHeader; + private $arrExportHeaderDetails; + + /** + * Anzahl der Herzen/Sterne + * @var int + */ + protected $intStars = 5; + + protected $label; + protected $labels; + + /** + * Initialize the controller + */ + public function __construct($objElement=array()) { + parent::__construct($objElement); + + $this->label = $GLOBALS['TL_CONFIG']['rating_type'] == 'hearts' ? $GLOBALS['TL_LANG']['rateit']['heart'] : $GLOBALS['TL_LANG']['rateit']['star']; + $this->labels = $GLOBALS['TL_CONFIG']['rating_type'] == 'hearts' ? $GLOBALS['TL_LANG']['rateit']['hearts'] : $GLOBALS['TL_LANG']['rateit']['stars']; + + $this->actions = array( + // act[0] strTemplate compiler + array('', 'rateitbe_ratinglist', 'listRatings' ), + array('reset_ratings', '', 'resetRatings' ), + array('view', 'rateitbe_ratingview', 'viewRating' ), + array('export', '', 'exportRatings' ), + array('exportDetails', '', 'exportRatingDetails' ), + ); + + $this->loadLanguageFile('rateit_backend'); + $this->arrExportHeader = &$GLOBALS['TL_LANG']['tl_rateit']['xls_headers']; + $this->arrExportHeaderDetails = &$GLOBALS['TL_LANG']['tl_rateit']['xls_headers_detail']; + } + + /** + * Generate module: + * - Display a wildcard in the back end + * - Select the template and compiler in the front end + * @return string + */ + public function generate() + { + $this->rateit = new \stdClass(); + $rateit = &$this->rateit; + $rateit->username = $this->BackendUser->username; + $rateit->isadmin = $this->BackendUser->isAdmin; + + $this->strTemplate = $this->actions[0][1]; + $this->compiler = $this->actions[0][2]; + + $act = \Input::get('act'); + if (!$act) $act = \Input::post('act'); + foreach ($this->actions as $action) { + if ($act == $action[0]) { + $this->parameter = $act; + $this->action = $action[0]; + $this->strTemplate = $action[1]; + $this->compiler = $action[2]; + break; + } + } + + $stars = intval($GLOBALS['TL_CONFIG']['rating_count']); + if ($stars > 0) { + $this->intStars = $stars; + } + + return str_replace(array('{{', '}}'), array('[{]', '[}]'), parent::generate()); + } // generate + + /** + * Compile module: common initializations and forwarding to distinct function compiler + */ + protected function compile() + { + // hide module? + $compiler = $this->compiler; + if ($compiler=='hide') return; + + // load other helpers + $this->tl_root = str_replace("\\",'/',TL_ROOT).'/'; + $this->tl_files = str_replace("\\",'/',$GLOBALS['TL_CONFIG']['uploadPath']).'/'; + $this->Template->rateit = $this->rateit; + + // complete rateit initialization + $rateit = &$this->rateit; + $rateit->f_link = $this->createUrl(array($this->action => $this->parameter)); + $rateit->f_action = $this->compiler; + $rateit->f_mode = $this->action; + $rateit->theme = new RateItBackend(); + $rateit->backLink = $this->getReferer(true); + $rateit->homeLink = $this->createUrl(); + + // execute compiler + $this->$compiler($this->parameter); + } // compile + + /** + * List the ratings + */ + protected function listRatings() + { + $rateit = &$this->Template->rateit; + $rateit->f_page = 0; + + // returning from submit? + if ($this->filterPost('rateit_action') == $rateit->f_action) { + // get url parameters + $rateit->f_typ = trim(\Input::post('rateit_typ')); + $rateit->f_active = trim(\Input::post('rateit_active')); + $rateit->f_order = trim(\Input::post('rateit_order')); + $rateit->f_page = trim(\Input::post('rateit_page')); + $rateit->f_find = trim(\Input::post('rateit_find')); + $this->Session->set( + 'rateit_settings', + array( + 'rateit_typ' => $rateit->f_typ, + 'rateit_order' => $rateit->f_order, + 'rateit_page' => $rateit->f_page, + 'rateit_find' => $rateit->f_find + ) + ); + } else { + $stg = $this->Session->get('rateit_settings'); + if (is_array($stg)) { + $rateit->f_typ = trim($stg['rateit_typ']); + $rateit->f_active = trim($stg['rateit_active']); + $rateit->f_order = trim($stg['rateit_order']); + $rateit->f_page = trim($stg['rateit_page']); + $rateit->f_find = trim($stg['rateit_find']); + } // if + } // if + + if ($rateit->f_order=='') $rateit->f_order = 'rating'; + //if (!isset($rateit->f_active)) $rateit->f_active = '-1'; + + if (isset($GLOBALS['TL_CONFIG']['rating_listsize'])) + $perpage = (int)trim($GLOBALS['TL_CONFIG']['rating_listsize']); + if (!isset($perpage) || $perpage < 0) $perpage = 10; + + if ($rateit->f_page>=0 && $perpage>0) { + $options['first'] = $rateit->f_page * $perpage; + $options['limit'] = $perpage; + } // if + if ($rateit->f_typ != '') $options['typ'] = $rateit->f_typ; + if ($rateit->f_active != '') $options['active'] = $rateit->f_active == '0' ? '' : $rateit->f_active; + if ($rateit->f_find != '') $options['find'] = $rateit->f_find; + + switch ($rateit->f_order) { + case 'title' : $options['order'] = 'title'; break; + case 'typ' : $options['order'] = 'typ'; break; + case 'createdat' : $options['order'] = 'createdat'; break; + default : $options['order'] = 'rating desc'; + } // switch + + $rateit->exportLink = $this->createUrl(array('act' => 'export')); + + // query extensions + $rateit->ratingitems = $this->getRatingItems($options); + if ($rateit->f_page>=0 && $perpage>0 && count($rateit->ratingitems)==0) { + $rateit->f_page = 0; + $options['first'] = 0; + $rateit->ratingitems = $this->getRatingItems($options); + } // if + + // add view links + foreach ($rateit->ratingitems as &$ext) { + $ext->viewLink = $this->createUrl(array('act' => 'view', 'rkey' => $ext->rkey, 'typ' => $ext->typ)); + $totrecs = $ext->totcount; + } // foreach + + // create pages list + $rateit->pages = array(); + if ($perpage > 0) { + $first = 1; + while ($totrecs > 0) { + $cnt = $totrecs > $perpage ? $perpage : $totrecs; + $rateit->pages[] = $first . ' - ' . ($first+$cnt-1); + $first += $cnt; + $totrecs -= $cnt; + } // while + } // if + } // listRatings + + /** + * Export all ratings as MS-Excel-File + */ + protected function exportRatings() + { + $this->import('String'); + $rateit = &$this->Template->rateit; + + $options['order'] = 'rating desc'; + + // query ratings + $rateit->ratingitems = $this->getRatingItems($options, true); + + $xls = new \xlsexport(); + $strXlsSheet = $GLOBALS['TL_LANG']['tl_rateit']['xls_sheetname_ratings']; + $xls->addworksheet($strXlsSheet); + + $intRowCounter = -1; + $intColCounter = 0; + + $intRowCounter++; + + // Header setzen + foreach(array_values($this->arrExportHeader) as $header) { + $xls->setcell(array("sheetname" => $strXlsSheet,"row" => $intRowCounter, "col" => $intColCounter, "data" => $header, "fontweight" => XLSFONT_BOLD, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL)); + $xls->setcolwidth($strXlsSheet, $intColCounter, 0x1aff); + $intColCounter++; + } + + $intRowCounter++; + + // Werte setzen + foreach($rateit->ratingitems as $item) { + $arrItem = (array)$item; + + $intColCounter = 0; + foreach(array_keys($this->arrExportHeader) as $key) { + $strVal = $arrItem[$key]; + $strVal = $this->String->decodeEntities($strVal); + $strVal = preg_replace(array('//si'), array("\n"), $strVal); + $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252'); + + $cellType = CELL_STRING; + switch ($key) { + case 'typ' : + $strVal = $GLOBALS['TL_LANG']['tl_rateit_type_options'][$strVal]; + break; + case 'createdat' : + $strVal = $strVal ? date($GLOBALS['TL_CONFIG']['datimFormat'], $strVal) : ''; + break; + case 'active' : + $strVal = $strVal == '1' ? 'Ja' : 'Nein'; + break; + case 'rating' : + if (!isset($strVal) || empty($strVal)) { + $strVal = '0'; + } + $cellType = CELL_FLOAT; + break; + case 'stars' : + case 'percent' : + case 'totalRatings' : + case 'rkey' : + $cellType = CELL_FLOAT; + break; + } + $xls->setcell(array("sheetname" => $strXlsSheet,"row" => $intRowCounter, "col" => $intColCounter, "data" => $strVal, "type" => $cellType, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL)); + $intColCounter++; + } + + $intRowCounter++; + } + + $xls->sendfile("export_rateit_" . date("Ymd_His") . ".xls"); + exit; + } // exportRatings + + /** + * Detailed view of one rating. + * @param string + */ + protected function viewRating() + { + $rateit = &$this->Template->rateit; + + $rateit->f_page = 0; + + // returning from submit? + if ($this->filterPost('rateit_action') == $rateit->f_action) { + // get url parameters + $rateit->f_page = trim(\Input::post('rateit_details_page')); + $this->Session->set( + 'rateit_settings', + array( + 'rateit_details_page' => $rateit->f_page + ) + ); + } else { + $stg = $this->Session->get('rateit_settings'); + if (is_array($stg)) { + $rateit->f_page = trim($stg['rateit_details_page']); + } // if + } // if + + $rkey = \Input::get('rkey'); + if (strstr($rkey, '|')) { + $arrRkey = explode('|', $rkey); + foreach ($arrRkey as $key) { + if (!is_numeric($key)) { + $this->redirect($rateit->homeLink); + exit; + } + $id = $rkey; + } + } else { + if (is_numeric($rkey)) { + $id = $rkey; + } else { + $this->redirect($rateit->homeLink); + exit; + } + } + + $typ = \Input::get('typ'); + + // compose base options + $options = array( + 'rkey' => $rkey, + 'typ' => $typ + ); + + $this->rateit->f_link = $this->createUrl(array('act' => 'view', 'rkey' => $rkey, 'typ' => $typ)); + + if (isset($GLOBALS['TL_CONFIG']['rating_listsize'])) + $perpage = (int)trim($GLOBALS['TL_CONFIG']['rating_listsize']); + if (!isset($perpage) || $perpage < 0) $perpage = 10; + + if ($rateit->f_page>=0 && $perpage>0) { + $options['first'] = $rateit->f_page * $perpage; + $options['limit'] = $perpage; + } // if + + $rateit->ratingitems = $this->getRatingItems($options, true); + if (count($rateit->ratingitems)<1) $this->redirect($rateit->homeLink); + $ext = &$rateit->ratingitems[0]; + + $ext->ratings = $this->getRatings($ext, $options); + if ($rateit->f_page>=0 && $perpage>0 && count($ext->ratings)==0) { + $rateit->f_page = 0; + $options['first'] = 0; + $rateit->ratings = $this->getRatings($ext, $options); + } // if + + if (count($ext->ratings) > 0) { + $totrecs = $ext->ratings[0]->totcount; + } else { + $totrecs = 0; + } + + // create pages list + $rateit->pages = array(); + if ($perpage > 0) { + $first = 1; + while ($totrecs > 0) { + $cnt = $totrecs > $perpage ? $perpage : $totrecs; + $rateit->pages[] = $first . ' - ' . ($first+$cnt-1); + $first += $cnt; + $totrecs -= $cnt; + } // while + } // if + + $rateit->exportLink = $this->createUrl(array('act' => 'exportDetails', 'rkey' => $rkey, 'typ' => $typ)); + + $ext->statistics = $this->getRatingStatistics($ext->item_id); + $ext->ratingsChartData = $this->getRatingsChartData($ext->statistics); + $ext->monthsChartData = $this->getMonthsChartData($ext->item_id); + } // viewRating + + protected function resetRatings() + { + $rateit = &$this->Template->rateit; + + // nothing checked? + $ids0 = \Input::post('selectedids'); + if (!is_array($ids0)) { + $this->redirect($rep->homeLink); return; + } + + foreach ($ids0 as $id) { + list($rkey, $typ) = explode('__', $id); + $pid = $this->Database->prepare('SELECT id FROM tl_rateit_items WHERE rkey=? and typ=?') + ->execute($rkey, $typ) + ->fetchRow(); + $this->Database->prepare('DELETE FROM tl_rateit_ratings WHERE pid=?') + ->execute($pid[0]); + } + + $this->redirect($rateit->homeLink); + + } // resetRatings + + /** + * Export the details of one rating as MS-Excel-File + */ + protected function exportRatingDetails() + { + $rkey = \Input::get('rkey'); + if (!is_numeric($rkey)) + $this->redirect($rateit->backLink); + $typ = \Input::get('typ'); + + $this->rateit->backLink = $this->createUrl(array('act' => 'view', 'rkey' => $rkey, 'typ' => $typ)); + + // compose base options + $options = array( + 'rkey' => $rkey, + 'typ' => $typ + ); + + $this->import('String'); + $rateit = &$this->Template->rateit; + + // query ratings + $rateit->ratingitems = $this->getRatingItems($options); + if (count($rateit->ratingitems)<1) $this->redirect($rateit->backLink); + $ext = &$rateit->ratingitems[0]; + $ext->ratings = $this->getRatings($ext); + $ext->statistics = $this->getRatingStatistics($ext->item_id); + + $xls = new \xlsexport(); + $strXlsSheet = $GLOBALS['TL_LANG']['tl_rateit']['xls_sheetname_rating']; + $xls->addworksheet($strXlsSheet); + + $intRowCounter = -1; + $intColCounter = 0; + + $intRowCounter++; + + // Header setzen + foreach(array_values($this->arrExportHeaderDetails) as $header) { + $xls->setcell(array("sheetname" => $strXlsSheet,"row" => $intRowCounter, "col" => $intColCounter, "data" => $header, "fontweight" => XLSFONT_BOLD, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL)); + $xls->setcolwidth($strXlsSheet, $intColCounter, 0x1aff); + $intColCounter++; + } + + $intRowCounter++; + + // Werte setzen + foreach($ext->ratings as $item) { + $arrItem = (array)$item; + + $intColCounter = 0; + foreach(array_keys($this->arrExportHeaderDetails) as $key) { + $strVal = $arrItem[$key]; + $strVal = $this->String->decodeEntities($strVal); + $strVal = preg_replace(array('//si'), array("\n"), $strVal); + $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252'); + + $cellType = CELL_STRING; + switch ($key) { + case 'createdat' : + $strVal = $strVal ? date($GLOBALS['TL_CONFIG']['datimFormat'], $strVal) : ''; + break; + case 'rating' : + if (!isset($strVal) || empty($strVal)) { + $strVal = '0'; + } + $cellType = CELL_FLOAT; + break; + case 'stars' : + case 'percent' : + case 'totalRatings' : + case 'rkey' : + $cellType = CELL_FLOAT; + break; + } + $xls->setcell(array("sheetname" => $strXlsSheet,"row" => $intRowCounter, "col" => $intColCounter, "data" => $strVal, "type" => $cellType, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL)); + $intColCounter++; + } + + $intRowCounter++; + } + + $xls->sendfile("export_rateit_" . date("Ymd_His") . ".xls"); + exit; + } // exportRatingDetails + + /** + * Create url for hyperlink to the current page. + * @param array $aParams Assiciative array with key/value pairs as parameters. + * @return string The create link. + */ + protected function createUrl($aParams = null) + { + return $this->createPageUrl(\Input::get('do'), $aParams); + } // createUrl + + /** + * Create url for hyperlink to an arbitrary page. + * @param string $aPage The page ID. + * @param array $aParams Assiciative array with key/value pairs as parameters. + * @return string The create link. + */ + protected function createPageUrl($aPage, $aParams = null) + { + $url = \Environment::get('script') . '?do='.$aPage; + if (is_array($aParams)) { + foreach ($aParams as $key => $val) + if ($val!='') + $url .= '&'.$key .'='.$val; + } + return $url; + } // createPageUrl + + /** + * Get post parameter and filter value. + * @param string $aKey The post key. When filtering html, remove all attribs and + * keep the plain tags. + * @param string $aMode '': no filtering + * 'nohtml': strip all html + * 'text': Keep tags p br ul li em + * @return string The filtered input. + */ + protected function filterPost($aKey, $aMode = '') + { + $v = trim(\Input::postRaw($aKey)); + if ($v == '' || $aMode=='') return $v; + switch ($aMode) { + case 'nohtml': + $v = strip_tags($v); + break; + case 'text': + $v = strip_tags($v, rateit_TEXTTAGS); + break; + } // switch + $v = preg_replace('/<(\w+) .*>/U', '<$1>', $v); + return $v; + } // filterPost + + protected function getRatingItems($aOptions, $noLimit=false) { + $sql = "SELECT i.id as item_id, + i.rkey AS rkey, + i.title as title, + i.typ as typ, + i.createdat as createdat, + i.active as active, + IFNULL(AVG(r.rating),0) AS rating, + COUNT( r.rating ) AS totalRatings + FROM tl_rateit_items i + LEFT OUTER JOIN tl_rateit_ratings r + ON (i.id = r.pid) + %w + GROUP BY rkey, title, item_id, typ, createdat, active + %o + %l"; + + $cntSql = "SELECT COUNT(*) FROM tl_rateit_items i %s"; + + $where = ''; + $firstWhere = true; + $limit = ''; + $order = ''; + + foreach ($aOptions as $k=>$v) { + if ($k == 'find') { + if (!$firstWhere) { + $where .= " AND"; + } + $where .= " title like '%$v%'"; + $firstWhere = false; + } + else if ($k != 'order' && $k != 'limit' && $k != 'first') { + if (!$firstWhere) { + $where .= " AND"; + } + $where .= " $k='$v'"; + $firstWhere = false; + } else { + if ($k == 'limit' && !$noLimit) { + $cntRows = $v; + } else if ($k == 'first' && !$noLimit) { + $first = $v; + } + } + } + + if (isset($cntRows) && isset($first)) { + $limit = "LIMIT $first, $cntRows"; + } + + if (strlen($where) > 0) { + $where = "WHERE ".$where; + } + + if (isset($aOptions['order']) && !empty($aOptions['order'])) + $order = "ORDER BY ".$aOptions['order']; + + $sql = str_replace('%o', $order, $sql); + $sql = str_replace('%w', $where, $sql); + $sql = str_replace('%l', $limit, $sql); + + $cntSql = str_replace('%s', $where, $cntSql); + + $count = $this->Database->prepare($cntSql) + ->execute() + ->fetchRow(); + + $arrRatingItems = $this->Database->prepare($sql) + ->execute() + ->fetchAllAssoc(); + $arrReturn = array(); + foreach ($arrRatingItems as $rating) { + if ($rating['active'] != '1') $rating['active'] = '0'; + $rating['percent'] = $rating['rating']; + $rating['rating'] = $this->percentToStars($rating['percent']); + $rating['stars'] = $this->intStars; + $rating['totcount'] = $count[0]; + $arrReturn[] = (object) $rating; + } + return $arrReturn; + } // getRatingItems + + protected function getRatings($ext, $options = array()) { + // Gesamtanzahl (für Paging wichtig) ermitteln + $cntSql = "SELECT COUNT(*) FROM tl_rateit_ratings r WHERE r.pid=$ext->item_id"; + $count = $this->Database->prepare($cntSql) + ->execute() + ->fetchRow(); + + foreach ($options as $k=>$v) { + if ($k == 'limit') { + $cntRows = $v; + } else if ($k == 'first') { + $first = $v; + } + } + + if (isset($cntRows) && isset($first)) { + $limit = "LIMIT $first, $cntRows"; + } + + $sql = "SELECT id AS rating_id, ip_address AS ip, memberid, rating, createdat + FROM tl_rateit_ratings r + WHERE r.pid=$ext->item_id + ORDER BY createdat DESC + %l"; + $sql = str_replace('%l', $limit, $sql); + + $arrRatings = $this->Database->prepare($sql) + ->execute() + ->fetchAllAssoc(); + $arrReturn = array(); + foreach ($arrRatings as $rating) { + $rating['percent'] = $rating['rating']; + $rating['rating'] = $this->percentToStars($rating['percent']); + $rating['stars'] = $this->intStars; + $rating['totcount'] = $count[0]; + if ($rating['memberid'] != null) { + $member = $this->Database->prepare("SELECT firstname, lastname FROM tl_member WHERE id=?") + ->limit(1) + ->execute($rating['memberid']) + ->fetchAssoc(); + $rating['member'] = $member['firstname']." ".$member['lastname']; + } + $arrReturn[] = (object) $rating; + } + return $arrReturn; + } // getRatings + + protected function getRatingStatistics($item_id) { + $sql = "SELECT rating, count(*) as count + FROM tl_rateit_ratings r + WHERE r.pid=$item_id + GROUP BY rating + ORDER BY rating"; + + $arrRatingStatistics = $this->Database->prepare($sql) + ->execute() + ->fetchAllAssoc(); + $arrReturn = array(); + foreach ($arrRatingStatistics as $rating) { + $rating['percent'] = $rating['rating']; + $rating['rating'] = $this->percentToStars($rating['percent']); + $arrReturn[$rating['percent']] = (object) $rating; + } + return $arrReturn; + } // getRatings + + protected function getRatingsChartData($statistics) { + $arr = array(); + $arr['cols'] = array(); + $arr['rows'] = array(); + + // Spalten anlegen + $arr['cols'][] = array('id'=>'rating', 'label'=>$GLOBALS['TL_LANG']['tl_rateit']['rating_chart_legend'][2], 'type'=>'string'); + $arr['cols'][] = array('id'=>'count', 'label'=>$GLOBALS['TL_LANG']['tl_rateit']['rating_chart_legend'][3], 'type'=>'number'); + + // Zeilen anlegen + foreach($statistics as $obj) { + $arr['rows'][] = array('c'=>array(array('v'=>$obj->rating.' '.($obj->rating == 1 ? $this->label : $this->labels)), array('v'=>(int)$obj->count, 'f'=>$obj->count.' '.$GLOBALS['TL_LANG']['tl_rateit']['vote'][$obj->count == 1 ? 0 : 1]))); + } + return json_encode($arr); + } + + protected function getMonthsChartData($item_id) { + + $sql = "SELECT count(*) AS anzahl, avg(rating) AS bewertung, month(date(FROM_UNIXTIME(createdat))) AS monat, year(date(FROM_UNIXTIME(createdat))) AS jahr + FROM tl_rateit_ratings r + WHERE r.pid=$item_id + GROUP BY monat, jahr + ORDER BY jahr DESC , monat DESC + LIMIT 0 , 12"; + + $arrResult = $this->Database->prepare($sql) + ->execute() + ->fetchAllAssoc(); + + $arrResult = array_reverse($arrResult); + + $this->loadLanguageFile('default'); + + $arr = array(); + $arr['cols'] = array(); + $arr['rows'] = array(); + + // Spalten anlegen + $arr['cols'][] = array('id'=>'month', 'label'=>$GLOBALS['TL_LANG']['tl_rateit']['month_chart_legend'][3], 'type'=>'string'); + $arr['cols'][] = array('id'=>'count', 'label'=>$GLOBALS['TL_LANG']['tl_rateit']['month_chart_legend'][4], 'type'=>'number'); + $arr['cols'][] = array('id'=>'avg', 'label'=>$GLOBALS['TL_LANG']['tl_rateit']['month_chart_legend'][2], 'type'=>'number'); + + // Zeilen anlegen + foreach($arrResult as $result) { + $month = $GLOBALS['TL_LANG']['MONTHS'][$result['monat']-1].' '.$result['jahr']; + $avgValue = round((float)(($result['bewertung']*$this->intStars)/100), 1); + $arr['rows'][] = array('c'=>array(array('v'=>$month), + array('v'=>(int)$result['anzahl']), + array('v'=>$avgValue))); + } + return json_encode($arr); + } + + protected function percentToStars($percent) { + $modifier = 100 / $this->intStars; + return round($percent / $modifier, 1); + } + + /** + * Convert encoding + * @return String + * @param $strString String to convert + * @param $from charset to convert from + * @param $to charset to convert to + */ + public function convertEncoding($strString, $from, $to) { + if (USE_MBSTRING) { + @mb_substitute_character('none'); + return @mb_convert_encoding($strString, $to, $from); + } + elseif (function_exists('iconv')) { + if (strlen($iconv = @iconv($from, $to . '//IGNORE', $strString))) { + return $iconv; + } + else { + return @iconv($from, $to, $strString); + } + } + return $strString; + } +} // class rateitBackendModule diff --git a/classes/RateItCE.php b/classes/RateItCE.php new file mode 100644 index 0000000..b7c4839 --- /dev/null +++ b/classes/RateItCE.php @@ -0,0 +1,51 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +/** + * Class RateItCE + */ +class RateItCE extends RateItHybrid +{ + + /** + * Initialize the controller + */ + public function __construct($objElement) { + parent::__construct($objElement); + } + + protected function getType() { + return 'ce'; + } +} + +?> \ No newline at end of file diff --git a/classes/RateItFaq.php b/classes/RateItFaq.php new file mode 100644 index 0000000..625f1fb --- /dev/null +++ b/classes/RateItFaq.php @@ -0,0 +1,159 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +class RateItFaq extends RateItFrontend { + + /** + * Initialize the controller + */ + public function __construct() { + parent::__construct(); + } + + public function getContentElementRateIt($objRow, $strBuffer) { + if ($objRow->type == 'module') { + $objModule = $this->Database->prepare("SELECT * FROM tl_module WHERE id=? AND type IN ('faqpage', 'faqreader')") + ->limit(1) + ->execute($objRow->module); + + if ($objModule->numRows == 1) { + $this->faq_categories = deserialize($objModule->faq_categories); + + if ($objModule->type == 'faqreader') { + $strBuffer = $this->generateForFaqReader($objModule, $strBuffer); + } else { + $strBuffer = $this->generateForFaqPage($objModule, $strBuffer); + } + + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.css||static'; + switch ($GLOBALS['TL_CONFIG']['rating_type']) { + case 'hearts' : + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.css||static'; + break; + default: + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.css||static'; + } + } + } + return $strBuffer; + } + + private function generateForFaqPage($objModule, $strBuffer) { + $objFaq = $this->Database + ->execute("SELECT *, author AS authorId, (SELECT headline FROM tl_faq_category WHERE tl_faq_category.id=tl_faq.pid) AS category, (SELECT name FROM tl_user WHERE tl_user.id=tl_faq.author) AS author FROM tl_faq WHERE pid IN(" . implode(',', array_map('intval', $this->faq_categories)) . ")" . (!BE_USER_LOGGED_IN ? " AND published=1" : "")); + + if ($objFaq->numRows < 1) { + return $strBuffer; + } + + $htmlBuffer = new \simple_html_dom(); + $htmlBuffer->load($strBuffer); + + $arrFaqs = $objFaq->fetchAllAssoc(); + foreach ($arrFaqs as $arrFaq) { + $rating = $this->generateSingle($arrFaq, $strBuffer); + + $h3 = $htmlBuffer->find('#'.$arrFaq['alias']); + if (is_array($h3) && count($h3) == 1) { + $section = $h3[0]->parent(); + + if ($arrFaq['rateit_position'] == 'before') { + $section->innertext = $rating.$section->innertext; + } else if ($arrFaq['rateit_position'] == 'after') { + $section->innertext = $section->innertext.$rating; + } + } + } + + $strBuffer = $htmlBuffer->save(); + + // Aufräumen + $htmlBuffer->clear(); + unset($htmlBuffer); + + return $strBuffer; + } + + private function generateForFaqReader($objModule, $strBuffer) { + // Set the item from the auto_item parameter + if ($GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) { + $this->Input->setGet('items', $this->Input->get('auto_item')); + } + + // Do not index or cache the page if no FAQ has been specified + if (!$this->Input->get('items')) { + return $strBuffer; + } + + $objFaq = $this->Database->prepare("SELECT *, author AS authorId, (SELECT title FROM tl_faq_category WHERE tl_faq_category.id=tl_faq.pid) AS category, (SELECT name FROM tl_user WHERE tl_user.id=tl_faq.author) AS author FROM tl_faq WHERE pid IN(" . implode(',', array_map('intval', $this->faq_categories)) . ") AND (id=? OR alias=?)" . (!BE_USER_LOGGED_IN ? " AND published=1" : "")) + ->limit(1) + ->execute((is_numeric($this->Input->get('items')) ? $this->Input->get('items') : 0), $this->Input->get('items')); + + if ($objFaq->numRows == 1) { + $arrFaq = $objFaq->fetchAssoc(); + + $rating = $this->generateSingle($arrFaq, $strBuffer); + } + + if ($arrFaq['rateit_position'] == 'before') { + $strBuffer = $rating.$strBuffer; + } else if ($arrFaq['rateit_position'] == 'after') { + $strBuffer = $strBuffer.$rating; + } + + return $strBuffer; + } + + private function generateSingle($arrFaq, $strBuffer) { + $rating = ''; + + if ($arrFaq['addRating']) { + $actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ='faq'") + ->execute($arrFaq['id']) + ->fetchAssoc(); + + if ($actRecord['active']) { + $this->import('rateit\\RateItRating', 'RateItRating'); + $this->RateItRating->rkey = $arrFaq['id']; + $this->RateItRating->ratingType = 'faq'; + $this->RateItRating->generate(); + + $rating = $this->RateItRating->output(); + } + } + + return $rating; + } +} +?> \ No newline at end of file diff --git a/classes/RateItFrontend.php b/classes/RateItFrontend.php new file mode 100644 index 0000000..d647c87 --- /dev/null +++ b/classes/RateItFrontend.php @@ -0,0 +1,157 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +/** + * Class RateItFrontend + */ +class RateItFrontend extends \Hybrid +{ + + /** + * Primary key + * @var string + */ + protected $strPk = 'id'; + + /** + * Typ + * @var string + */ + protected $strType = 'hearts'; + + /** + * Template + * @var string + */ + protected $strTemplate = 'rateit_default'; + + /** + * Anzahl der Herzen/Sterne + * @var int + */ + protected $intStars = 5; + + /** + * Textposition + * @var string + */ + protected $strTextPosition = 'after'; + + /** + * Initialize the controller + */ + public function __construct($objElement=array()) { + if (!empty($objElement)) { + if ($objElement instanceof \Model) { + $this->strTable = $objElement->getTable(); + } + elseif ($objElement instanceof \Model\Collection) { + $this->strTable = $objElement->current()->getTable(); + } + + $this->strKey = $this->strPk; + } + + $stars = intval($GLOBALS['TL_CONFIG']['rating_count']); + if ($stars > 0) { + $this->intStars = $stars; + } + parent::__construct($objElement); + } + + /** + * Display a wildcard in the back end + * @return string + */ + public function generate() { + return parent::generate(); + $this->loadLanguageFile('default'); + $this->strType = $GLOBALS['TL_CONFIG']['rating_type']; + $stars = intval($GLOBALS['TL_CONFIG']['rating_count']); + if ($stars > 0) { + $this->intStars = $stars; + } + $this->strTemplate = $GLOBALS['TL_CONFIG']['rating_template']; + $this->strTextPosition = $GLOBALS['TL_CONFIG']['rating_textposition']; + } + + + /** + * Generate the module/content element + */ + protected function compile() { + } + + public function getStarMessage($rating) { + $this->loadLanguageFile('default'); + $stars = $this->percentToStars($rating['rating']); + preg_match('/^.*\[(.+)\|(.+)\].*$/i', $GLOBALS['TL_CONFIG']['rating_description'], $labels); + if (!is_array($labels) || !count($labels) == 2 || !count($labels) == 3) { + $label = ($rating[totalRatings] > 1 || $rating[totalRatings] == 0) || !$rating ? $GLOBALS['TL_LANG']['rateit']['rating_label'][1] : $GLOBALS['TL_LANG']['rateit']['rating_label'][0]; + $description = '%current%/%max% %type% (%count% ['.$GLOBALS['TL_LANG']['tl_rateit']['vote'][0].'|'.$GLOBALS['TL_LANG']['tl_rateit']['vote'][1].'])'; + } else { + $label = count($labels) == 2 ? $labels[1] : ($rating[totalRatings] > 1 || $rating[totalRatings] == 0) || !$rating ? $labels[2] : $labels[1]; + $description = $GLOBALS['TL_CONFIG']['rating_description']; + } + $actValue = $rating === false ? 0 : $rating[totalRatings]; + $type = $GLOBALS['TL_CONFIG']['rating_type'] == 'hearts' ? $GLOBALS['TL_LANG']['rateit']['hearts'] : $GLOBALS['TL_LANG']['rateit']['stars']; +// return str_replace('.', ',', $stars)."/$this->intStars ".$type." ($actValue $label)"; + $description = str_replace('%current%', str_replace('.', ',', $stars), $description); + $description = str_replace('%max%', $this->intStars, $description); + $description = str_replace('%type%', $type, $description); + $description = str_replace('%count%', $actValue, $description); + $description = preg_replace('/^(.*)(\[.*\])(.*)$/i', "\\1$label\\3", $description); + return $description; + } + + public function loadRating($rkey, $typ) { + $SQL_GET_RATINGS = "SELECT i.rkey AS rkey, + i.title AS title, + IFNULL(AVG(r.rating),0) AS rating, + COUNT( r.rating ) AS totalRatings + FROM tl_rateit_items i + LEFT OUTER JOIN tl_rateit_ratings r + ON ( i.id = r.pid ) WHERE i.rkey = ? and typ=? and active='1' + GROUP BY i.rkey;"; + $result = $this->Database->prepare($SQL_GET_RATINGS) + ->execute($rkey, $typ) + ->fetchAssoc(); + return $result; + } + + protected function percentToStars($percent) { + $modifier = 100 / $this->intStars; + return round($percent / $modifier, 1); + } +} + +?> \ No newline at end of file diff --git a/classes/RateItHybrid.php b/classes/RateItHybrid.php new file mode 100644 index 0000000..173219f --- /dev/null +++ b/classes/RateItHybrid.php @@ -0,0 +1,116 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +/** + * Class RateItHybrid + */ +abstract class RateItHybrid extends RateItFrontend +{ + //protected $intStars = 5; + + /** + * Initialize the controller + */ + public function __construct($objElement) { + parent::__construct($objElement); + } + + /** + * Display a wildcard in the back end + * @return string + */ + public function generate() { + if (TL_MODE == 'BE') { + $objTemplate = new \BackendTemplate('be_wildcard'); + + $objTemplate->wildcard = '### Rate IT ###'; + $objTemplate->title = $this->rateit_title; + $objTemplate->id = $this->id; + $objTemplate->link = $this->name; + $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; + + return $objTemplate->parse(); + } + + $this->strTemplate = $GLOBALS['TL_CONFIG']['rating_template']; + + $this->strType = $GLOBALS['TL_CONFIG']['rating_type']; + $this->strTextPosition = $GLOBALS['TL_CONFIG']['rating_textposition']; + + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.css||static'; + switch ($this->strType) { + case 'hearts' : + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.css||static'; + break; + default: + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.css||static'; + } + + return parent::generate(); + } + + /** + * Generate the module/content element + */ + protected function compile() { + $this->Template = new \FrontendTemplate($this->strTemplate); + + $this->Template->setData($this->arrData); + + $rating = $this->loadRating($this->getParent()->id, $this->getType()); + $ratingId = $this->getParent()->id; + $stars = !$rating ? 0 : $this->percentToStars($rating['rating']); + $percent = round($rating['rating'], 0)."%"; + + $this->Template->descriptionId = 'rateItRating-'.$ratingId.'-description'; + $this->Template->description = $this->getStarMessage($rating); + $this->Template->id = 'rateItRating-'.$ratingId.'-'.$this->getType().'-'.$stars.'_'.$this->intStars; + $this->Template->rateit_class = 'rateItRating'; + $this->Template->itemreviewed = $rating['title']; + $this->Template->actRating = $this->percentToStars($rating['rating']); + $this->Template->maxRating = $this->intStars; + $this->Template->votes = $rating[totalRatings]; + + if ($this->strTextPosition == "before") { + $this->Template->showBefore = true; + } + else if ($this->strTextPosition == "after") { + $this->Template->showAfter = true; + } + + return parent::compile(); + } +} + +?> \ No newline at end of file diff --git a/classes/RateItModule.php b/classes/RateItModule.php new file mode 100644 index 0000000..cf97965 --- /dev/null +++ b/classes/RateItModule.php @@ -0,0 +1,51 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +/** + * Class RateItModule + */ +class RateItModule extends RateItHybrid +{ + + /** + * Initialize the controller + */ + public function __construct($objElement) { + parent::__construct($objElement); + } + + protected function getType() { + return 'module'; + } +} + +?> \ No newline at end of file diff --git a/classes/RateItNews.php b/classes/RateItNews.php new file mode 100644 index 0000000..9742722 --- /dev/null +++ b/classes/RateItNews.php @@ -0,0 +1,85 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +class RateItNews extends RateItFrontend { + + /** + * Initialize the controller + */ + public function __construct() { + parent::__construct(); + } + + public function parseArticle($objTemplate, $objArticle, $caller) { + if (strpos(get_class($caller), "ModuleNews") !== false && + $objArticle['addRating']) { + $ratingId = $objTemplate->id; + $rating = $this->loadRating($ratingId, 'news'); + $stars = !$rating ? 0 : $this->percentToStars($rating['rating']); + $percent = round($rating['rating'], 0)."%"; + + $objTemplate->descriptionId = 'rateItRating-'.$ratingId.'-description'; + $objTemplate->description = $this->getStarMessage($rating); + $objTemplate->id = 'rateItRating-'.$ratingId.'-news-'.$stars.'_'.$this->intStars; + $objTemplate->rateit_class = 'rateItRating'; + $objTemplate->itemreviewed = $rating['title']; + $objTemplate->actRating = $this->percentToStars($rating['rating']); + $objTemplate->maxRating = $this->intStars; + $objTemplate->votes = $rating[totalRatings]; + + if ($this->strTextPosition == "before") { + $objTemplate->showBefore = true; + } + else if ($this->strTextPosition == "after") { + $objTemplate->showAfter = true; + } + + if ($objArticle['rateit_position'] == 'before') { + $objTemplate->rateit_rating_before = true; + } else if ($objArticle['rateit_position'] == 'after') { + $objTemplate->rateit_rating_after = true; + } + + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.css||static'; + switch ($GLOBALS['TL_CONFIG']['rating_type']) { + case 'hearts' : + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.css||static'; + break; + default: + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.css||static'; + } + } + } +} +?> \ No newline at end of file diff --git a/classes/RateItPage.php b/classes/RateItPage.php new file mode 100644 index 0000000..112b1bf --- /dev/null +++ b/classes/RateItPage.php @@ -0,0 +1,110 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +class RateItPage extends \Frontend { + + /** + * Initialize the controller + */ + public function __construct() { + parent::__construct(); + + $this->loadDataContainer('settings'); + } + + public function outputFrontendTemplate($strContent, $strTemplate) { + global $objPage; + + if ($objPage->addRating && !($strTemplate == $GLOBALS['TL_CONFIG']['rating_template'])) { + $actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ='page'") + ->execute($objPage->id) + ->fetchAssoc(); + + if ($actRecord['active']) { + $this->import('rateit\\RateItRating', 'RateItRating'); + $this->RateItRating->rkey = $objPage->id; + $this->RateItRating->generate(); + + $rating = $this->RateItRating->output(); + $rating .= $this->includeJs(); + $rating .= $this->includeCss(); + + $posMainDiv = strpos($strContent, '
'); + $posInsideDiv = strpos($strContent, '
', $posMainDiv); + + $return = substr($strContent, 0, $posInsideDiv).'
'; + $return .= $rating; + $return .= substr($strContent, $posInsideDiv + strlen('
') + 3); + $strContent = $return; + } + } + return $strContent; + } + + private function includeCss() { + $included = false; + $strHeadTags = ''; + foreach ($GLOBALS['TL_CSS'] as $script) { + if ($script == 'system/modules/rateit/public/css/rateit.css') { + $included = true; + } + } + + if (!$included) { + $strHeadTags = ''; + switch ($GLOBALS['TL_CONFIG']['rating_type']) { + case 'hearts' : + $strHeadTags .= ''; + break; + default: + $strHeadTags .= ''; + } + } + return $strHeadTags; + } + + private function includeJs() { + $included = false; + $strHeadTags = ''; + foreach ($GLOBALS['TL_JAVASCRIPT'] as $script) { + if ($script == 'system/modules/rateit/public/js/rateit.js') { + $included = true; + } + } + + if (!$included) { + $strHeadTags = 'outputFormat == 'xhtml') ? ' type="text/javascript"' : '') . ' src="' . $this->addStaticUrlTo('system/modules/rateit/public/js/onReadyRateIt.js') . '">' . "\n"; + $strHeadTags .= 'outputFormat == 'xhtml') ? ' type="text/javascript"' : '') . ' src="' . $this->addStaticUrlTo('system/modules/rateit/public/js/rateit.js') . '">' . "\n"; + } + return $strHeadTags; + } +} +?> \ No newline at end of file diff --git a/classes/RateItRating.php b/classes/RateItRating.php new file mode 100644 index 0000000..5b3d0f5 --- /dev/null +++ b/classes/RateItRating.php @@ -0,0 +1,96 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +class RateItRating extends RateItFrontend { + + /** + * RatingKey + * @var int + */ + public $rkey = 0; + + public $ratingType = 'page'; + + /** + * Initialize the controller + */ + public function __construct($objElement=array()) { + parent::__construct($objElement); + } + + /** + * Display a wildcard in the back end + * @return string + */ + public function generate() { + parent::generate(); + } + + /** + * Compile + */ + protected function compile() + { + $this->loadLanguageFile('default'); + + $this->Template = new \FrontendTemplate($this->strTemplate); + $this->Template->setData($this->arrData); + + $rating = $this->loadRating($this->rkey, $this->ratingType); + $ratingId = $this->rkey; + $stars = !$rating ? 0 : $this->percentToStars($rating['rating']); + $percent = round($rating['rating'], 0)."%"; + + $this->Template->descriptionId = 'rateItRating-'.$ratingId.'-description'; + $this->Template->description = $this->getStarMessage($rating); + $this->Template->id = 'rateItRating-'.$ratingId.'-'.$this->ratingType.'-'.$stars.'_'.$this->intStars; + $this->Template->class = 'rateItRating'; + $this->Template->itemreviewed = $rating['title']; + $this->Template->actRating = $this->percentToStars($rating['rating']); + $this->Template->maxRating = $this->intStars; + $this->Template->votes = $rating[totalRatings]; + + if ($this->strTextPosition == "before") { + $this->Template->showBefore = true; + } + else if ($this->strTextPosition == "after") { + $this->Template->showAfter = true; + } + + return $this->Template->parse(); + } + + public function output() { + return $this->compile(); + } +} + +?> diff --git a/classes/RateItTopRatingsModule.php b/classes/RateItTopRatingsModule.php new file mode 100644 index 0000000..8b0495c --- /dev/null +++ b/classes/RateItTopRatingsModule.php @@ -0,0 +1,142 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @license GNU/LGPL + * @filesource + */ + +namespace cgoIT\rateit; + +/** + * Class RateItTopRatingsModule + */ +class RateItTopRatingsModule extends RateItFrontend +{ + //protected $intStars = 5; + + /** + * Initialize the controller + */ + public function __construct($objElement) { + parent::__construct($objElement); + + $this->strKey = "rateit_top_ratings"; + } + + /** + * Display a wildcard in the back end + * @return string + */ + public function generate() { + if (TL_MODE == 'BE') { + $objTemplate = new \BackendTemplate('be_wildcard'); + + $objTemplate->wildcard = '### Rate IT Best/Most Ratings ###'; + $objTemplate->title = $this->name; + $objTemplate->id = $this->id; + $objTemplate->link = $this->name; + $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; + + return $objTemplate->parse(); + } + + $this->strTemplate = $this->rateit_template; + + $this->arrTypes = deserialize($this->rateit_types); + + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.css||static'; + switch ($GLOBALS['TL_CONFIG']['rating_type']) { + case 'hearts' : + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.css||static'; + break; + default: + $GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.css||static'; + } + + return parent::generate(); + } + + /** + * Generate the module/content element + */ + protected function compile() { + $this->Template = new \FrontendTemplate($this->strTemplate); + + $this->Template->setData($this->arrData); + + $this->import("\\Database", "Database"); + $arrResult = $this->Database->prepare("SELECT i.id AS item_id, + i.rkey AS rkey, + i.title AS title, + i.typ AS typ, + i.createdat AS createdat, + i.active AS active, + IFNULL(AVG(r.rating),0) AS best, + COUNT( r.rating ) AS most + FROM tl_rateit_items i + LEFT OUTER JOIN tl_rateit_ratings r + ON (i.id = r.pid) + WHERE + typ IN ('".implode("', '", $this->arrTypes)."') + GROUP BY rkey, title, item_id, typ, createdat, active + ORDER BY ".$this->rateit_toptype." DESC") + ->limit($this->rateit_count) + ->execute() + ->fetchAllAssoc(); + + $objReturn = array(); + foreach ($arrResult as $result) { + $return = new \stdClass(); + $return->title = $result['title']; + $return->typ = $result['typ']; + + // ID ermitteln + $stars = $this->percentToStars($result['best']); + $return->rateItID = 'rateItRating-'.$result['rkey'].'-'.$result['typ'].'-'. + $stars.'_'.intval($GLOBALS['TL_CONFIG']['rating_count']); + $return->descriptionId = 'rateItRating-'.$result['rkey'].'-description'; + + $return->rateit_class = 'rateItRating'; + + // Beschriftung ermitteln + $rating = array(); + $rating['totalRatings'] = $result['most']; + $rating['rating'] = $result['best']; + $return->description = $this->getStarMessage($rating); + + $return->rating = $result['best']; + $return->count = $result['most']; + $return->rel = 'not-rateable'; + $objReturn[] = $return; + } + + $this->Template->arrRatings = $objReturn; + } +} + +?> \ No newline at end of file diff --git a/classes/extern/simple_html_dom.php b/classes/extern/simple_html_dom.php new file mode 100644 index 0000000..9a7b2f6 --- /dev/null +++ b/classes/extern/simple_html_dom.php @@ -0,0 +1,1721 @@ +size is the "real" number of bytes the dom was created from. + * but for most purposes, it's a really good estimation. + * Paperg - Added the forceTagsClosed to the dom constructor. Forcing tags closed is great for malformed html, but it CAN lead to parsing errors. + * Allow the user to tell us how much they trust the html. + * Paperg add the text and plaintext to the selectors for the find syntax. plaintext implies text in the innertext of a node. text implies that the tag is a text node. + * This allows for us to find tags based on the text they contain. + * Create find_ancestor_tag to see if a tag is - at any level - inside of another specific tag. + * Paperg: added parse_charset so that we know about the character set of the source document. + * NOTE: If the user's system has a routine called get_last_retrieve_url_contents_content_type availalbe, we will assume it's returning the content-type header from the + * last transfer or curl_exec, and we will parse that and use it in preference to any other method of charset detection. + * + * Found infinite loop in the case of broken html in restore_noise. Rewrote to protect from that. + * PaperG (John Schlick) Added get_display_size for "IMG" tags. + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @author S.C. Chen + * @author John Schlick + * @author Rus Carroll + * @version 1.5 ($Rev: 196 $) + * @package PlaceLocalInclude + * @subpackage simple_html_dom + */ + +/** + * All of the Defines for the classes below. + * @author S.C. Chen + */ +define('HDOM_TYPE_ELEMENT', 1); +define('HDOM_TYPE_COMMENT', 2); +define('HDOM_TYPE_TEXT', 3); +define('HDOM_TYPE_ENDTAG', 4); +define('HDOM_TYPE_ROOT', 5); +define('HDOM_TYPE_UNKNOWN', 6); +define('HDOM_QUOTE_DOUBLE', 0); +define('HDOM_QUOTE_SINGLE', 1); +define('HDOM_QUOTE_NO', 3); +define('HDOM_INFO_BEGIN', 0); +define('HDOM_INFO_END', 1); +define('HDOM_INFO_QUOTE', 2); +define('HDOM_INFO_SPACE', 3); +define('HDOM_INFO_TEXT', 4); +define('HDOM_INFO_INNER', 5); +define('HDOM_INFO_OUTER', 6); +define('HDOM_INFO_ENDSPACE',7); +define('DEFAULT_TARGET_CHARSET', 'UTF-8'); +define('DEFAULT_BR_TEXT', "\r\n"); +define('DEFAULT_SPAN_TEXT', " "); +define('MAX_FILE_SIZE', 600000); +// helper functions +// ----------------------------------------------------------------------------- +// get html dom from file +// $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1. +function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) +{ + // We DO force the tags to be terminated. + $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); + // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done. + $contents = file_get_contents($url, $use_include_path, $context, $offset); + // Paperg - use our own mechanism for getting the contents as we want to control the timeout. + //$contents = retrieve_url_contents($url); + if (empty($contents) || strlen($contents) > MAX_FILE_SIZE) + { + return false; + } + // The second parameter can force the selectors to all be lowercase. + $dom->load($contents, $lowercase, $stripRN); + return $dom; +} + +// get html dom from string +function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) +{ + $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); + if (empty($str) || strlen($str) > MAX_FILE_SIZE) + { + $dom->clear(); + return false; + } + $dom->load($str, $lowercase, $stripRN); + return $dom; +} + +// dump html dom tree +function dump_html_tree($node, $show_attr=true, $deep=0) +{ + $node->dump($node); +} + + +/** + * simple html dom node + * PaperG - added ability for "find" routine to lowercase the value of the selector. + * PaperG - added $tag_start to track the start position of the tag in the total byte index + * + * @package PlaceLocalInclude + */ +class simple_html_dom_node +{ + public $nodetype = HDOM_TYPE_TEXT; + public $tag = 'text'; + public $attr = array(); + public $children = array(); + public $nodes = array(); + public $parent = null; + // The "info" array - see HDOM_INFO_... for what each element contains. + public $_ = array(); + public $tag_start = 0; + private $dom = null; + + function __construct($dom) + { + $this->dom = $dom; + $dom->nodes[] = $this; + } + + function __destruct() + { + $this->clear(); + } + + function __toString() + { + return $this->outertext(); + } + + // clean up memory due to php5 circular references memory leak... + function clear() + { + $this->dom = null; + $this->nodes = null; + $this->parent = null; + $this->children = null; + } + + // dump node's tree + function dump($show_attr=true, $deep=0) + { + $lead = str_repeat(' ', $deep); + + echo $lead.$this->tag; + if ($show_attr && count($this->attr)>0) + { + echo '('; + foreach ($this->attr as $k=>$v) + echo "[$k]=>\"".$this->$k.'", '; + echo ')'; + } + echo "\n"; + + if ($this->nodes) + { + foreach ($this->nodes as $c) + { + $c->dump($show_attr, $deep+1); + } + } + } + + + // Debugging function to dump a single dom node with a bunch of information about it. + function dump_node($echo=true) + { + + $string = $this->tag; + if (count($this->attr)>0) + { + $string .= '('; + foreach ($this->attr as $k=>$v) + { + $string .= "[$k]=>\"".$this->$k.'", '; + } + $string .= ')'; + } + if (count($this->_)>0) + { + $string .= ' $_ ('; + foreach ($this->_ as $k=>$v) + { + if (is_array($v)) + { + $string .= "[$k]=>("; + foreach ($v as $k2=>$v2) + { + $string .= "[$k2]=>\"".$v2.'", '; + } + $string .= ")"; + } else { + $string .= "[$k]=>\"".$v.'", '; + } + } + $string .= ")"; + } + + if (isset($this->text)) + { + $string .= " text: (" . $this->text . ")"; + } + + $string .= " HDOM_INNER_INFO: '"; + if (isset($node->_[HDOM_INFO_INNER])) + { + $string .= $node->_[HDOM_INFO_INNER] . "'"; + } + else + { + $string .= ' NULL '; + } + + $string .= " children: " . count($this->children); + $string .= " nodes: " . count($this->nodes); + $string .= " tag_start: " . $this->tag_start; + $string .= "\n"; + + if ($echo) + { + echo $string; + return; + } + else + { + return $string; + } + } + + // returns the parent of node + // If a node is passed in, it will reset the parent of the current node to that one. + function parent($parent=null) + { + // I am SURE that this doesn't work properly. + // It fails to unset the current node from it's current parents nodes or children list first. + if ($parent !== null) + { + $this->parent = $parent; + $this->parent->nodes[] = $this; + $this->parent->children[] = $this; + } + + return $this->parent; + } + + // verify that node has children + function has_child() + { + return !empty($this->children); + } + + // returns children of node + function children($idx=-1) + { + if ($idx===-1) + { + return $this->children; + } + if (isset($this->children[$idx])) return $this->children[$idx]; + return null; + } + + // returns the first child of node + function first_child() + { + if (count($this->children)>0) + { + return $this->children[0]; + } + return null; + } + + // returns the last child of node + function last_child() + { + if (($count=count($this->children))>0) + { + return $this->children[$count-1]; + } + return null; + } + + // returns the next sibling of node + function next_sibling() + { + if ($this->parent===null) + { + return null; + } + + $idx = 0; + $count = count($this->parent->children); + while ($idx<$count && $this!==$this->parent->children[$idx]) + { + ++$idx; + } + if (++$idx>=$count) + { + return null; + } + return $this->parent->children[$idx]; + } + + // returns the previous sibling of node + function prev_sibling() + { + if ($this->parent===null) return null; + $idx = 0; + $count = count($this->parent->children); + while ($idx<$count && $this!==$this->parent->children[$idx]) + ++$idx; + if (--$idx<0) return null; + return $this->parent->children[$idx]; + } + + // function to locate a specific ancestor tag in the path to the root. + function find_ancestor_tag($tag) + { + global $debugObject; + if (is_object($debugObject)) { $debugObject->debugLogEntry(1); } + + // Start by including ourselves in the comparison. + $returnDom = $this; + + while (!is_null($returnDom)) + { + if (is_object($debugObject)) { $debugObject->debugLog(2, "Current tag is: " . $returnDom->tag); } + + if ($returnDom->tag == $tag) + { + break; + } + $returnDom = $returnDom->parent; + } + return $returnDom; + } + + // get dom node's inner html + function innertext() + { + if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; + if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + + $ret = ''; + foreach ($this->nodes as $n) + $ret .= $n->outertext(); + return $ret; + } + + // get dom node's outer text (with tag) + function outertext() + { + global $debugObject; + if (is_object($debugObject)) + { + $text = ''; + if ($this->tag == 'text') + { + if (!empty($this->text)) + { + $text = " with text: " . $this->text; + } + } + $debugObject->debugLog(1, 'Innertext of tag: ' . $this->tag . $text); + } + + if ($this->tag==='root') return $this->innertext(); + + // trigger callback + if ($this->dom && $this->dom->callback!==null) + { + call_user_func_array($this->dom->callback, array($this)); + } + + if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER]; + if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + + // render begin tag + if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) + { + $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup(); + } else { + $ret = ""; + } + + // render inner text + if (isset($this->_[HDOM_INFO_INNER])) + { + // If it's a br tag... don't return the HDOM_INNER_INFO that we may or may not have added. + if ($this->tag != "br") + { + $ret .= $this->_[HDOM_INFO_INNER]; + } + } else { + if ($this->nodes) + { + foreach ($this->nodes as $n) + { + $ret .= $this->convert_text($n->outertext()); + } + } + } + + // render end tag + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) + $ret .= 'tag.'>'; + return $ret; + } + + // get dom node's plain text + function text() + { + if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; + switch ($this->nodetype) + { + case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + case HDOM_TYPE_COMMENT: return ''; + case HDOM_TYPE_UNKNOWN: return ''; + } + if (strcasecmp($this->tag, 'script')===0) return ''; + if (strcasecmp($this->tag, 'style')===0) return ''; + + $ret = ''; + // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. + // NOTE: This indicates that there is a problem where it's set to NULL without a clear happening. + // WHY is this happening? + if (!is_null($this->nodes)) + { + foreach ($this->nodes as $n) + { + $ret .= $this->convert_text($n->text()); + } + + // If this node is a span... add a space at the end of it so multiple spans don't run into each other. This is plaintext after all. + if ($this->tag == "span") + { + $ret .= $this->dom->default_span_text; + } + + + } + return $ret; + } + + function xmltext() + { + $ret = $this->innertext(); + $ret = str_ireplace('', '', $ret); + return $ret; + } + + // build node's text with tag + function makeup() + { + // text, comment, unknown + if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + + $ret = '<'.$this->tag; + $i = -1; + + foreach ($this->attr as $key=>$val) + { + ++$i; + + // skip removed attribute + if ($val===null || $val===false) + continue; + + $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; + //no value attr: nowrap, checked selected... + if ($val===true) + $ret .= $key; + else { + switch ($this->_[HDOM_INFO_QUOTE][$i]) + { + case HDOM_QUOTE_DOUBLE: $quote = '"'; break; + case HDOM_QUOTE_SINGLE: $quote = '\''; break; + default: $quote = ''; + } + $ret .= $key.$this->_[HDOM_INFO_SPACE][$i][1].'='.$this->_[HDOM_INFO_SPACE][$i][2].$quote.$val.$quote; + } + } + $ret = $this->dom->restore_noise($ret); + return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>'; + } + + // find elements by css selector + //PaperG - added ability for find to lowercase the value of the selector. + function find($selector, $idx=null, $lowercase=false) + { + $selectors = $this->parse_selector($selector); + if (($count=count($selectors))===0) return array(); + $found_keys = array(); + + // find each selector + for ($c=0; $c<$count; ++$c) + { + // The change on the below line was documented on the sourceforge code tracker id 2788009 + // used to be: if (($levle=count($selectors[0]))===0) return array(); + if (($levle=count($selectors[$c]))===0) return array(); + if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); + + $head = array($this->_[HDOM_INFO_BEGIN]=>1); + + // handle descendant selectors, no recursive! + for ($l=0; $l<$levle; ++$l) + { + $ret = array(); + foreach ($head as $k=>$v) + { + $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k]; + //PaperG - Pass this optional parameter on to the seek function. + $n->seek($selectors[$c][$l], $ret, $lowercase); + } + $head = $ret; + } + + foreach ($head as $k=>$v) + { + if (!isset($found_keys[$k])) + $found_keys[$k] = 1; + } + } + + // sort keys + ksort($found_keys); + + $found = array(); + foreach ($found_keys as $k=>$v) + $found[] = $this->dom->nodes[$k]; + + // return nth-element or array + if (is_null($idx)) return $found; + else if ($idx<0) $idx = count($found) + $idx; + return (isset($found[$idx])) ? $found[$idx] : null; + } + + // seek for given conditions + // PaperG - added parameter to allow for case insensitive testing of the value of a selector. + protected function seek($selector, &$ret, $lowercase=false) + { + global $debugObject; + if (is_object($debugObject)) { $debugObject->debugLogEntry(1); } + + list($tag, $key, $val, $exp, $no_key) = $selector; + + // xpath index + if ($tag && $key && is_numeric($key)) + { + $count = 0; + foreach ($this->children as $c) + { + if ($tag==='*' || $tag===$c->tag) { + if (++$count==$key) { + $ret[$c->_[HDOM_INFO_BEGIN]] = 1; + return; + } + } + } + return; + } + + $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0; + if ($end==0) { + $parent = $this->parent; + while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) { + $end -= 1; + $parent = $parent->parent; + } + $end += $parent->_[HDOM_INFO_END]; + } + + for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) { + $node = $this->dom->nodes[$i]; + + $pass = true; + + if ($tag==='*' && !$key) { + if (in_array($node, $this->children, true)) + $ret[$i] = 1; + continue; + } + + // compare tag + if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;} + // compare key + if ($pass && $key) { + if ($no_key) { + if (isset($node->attr[$key])) $pass=false; + } else { + if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; + } + } + // compare value + if ($pass && $key && $val && $val!=='*') { + // If they have told us that this is a "plaintext" search then we want the plaintext of the node - right? + if ($key == "plaintext") { + // $node->plaintext actually returns $node->text(); + $nodeKeyValue = $node->text(); + } else { + // this is a normal search, we want the value of that attribute of the tag. + $nodeKeyValue = $node->attr[$key]; + } + if (is_object($debugObject)) {$debugObject->debugLog(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);} + + //PaperG - If lowercase is set, do a case insensitive test of the value of the selector. + if ($lowercase) { + $check = $this->match($exp, strtolower($val), strtolower($nodeKeyValue)); + } else { + $check = $this->match($exp, $val, $nodeKeyValue); + } + if (is_object($debugObject)) {$debugObject->debugLog(2, "after match: " . ($check ? "true" : "false"));} + + // handle multiple class + if (!$check && strcasecmp($key, 'class')===0) { + foreach (explode(' ',$node->attr[$key]) as $k) { + // Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form. + if (!empty($k)) { + if ($lowercase) { + $check = $this->match($exp, strtolower($val), strtolower($k)); + } else { + $check = $this->match($exp, $val, $k); + } + if ($check) break; + } + } + } + if (!$check) $pass = false; + } + if ($pass) $ret[$i] = 1; + unset($node); + } + // It's passed by reference so this is actually what this function returns. + if (is_object($debugObject)) {$debugObject->debugLog(1, "EXIT - ret: ", $ret);} + } + + protected function match($exp, $pattern, $value) { + global $debugObject; + if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} + + switch ($exp) { + case '=': + return ($value===$pattern); + case '!=': + return ($value!==$pattern); + case '^=': + return preg_match("/^".preg_quote($pattern,'/')."/", $value); + case '$=': + return preg_match("/".preg_quote($pattern,'/')."$/", $value); + case '*=': + if ($pattern[0]=='/') { + return preg_match($pattern, $value); + } + return preg_match("/".$pattern."/i", $value); + } + return false; + } + + protected function parse_selector($selector_string) { + global $debugObject; + if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} + + // pattern of CSS selectors, modified from mootools + // Paperg: Add the colon to the attrbute, so that it properly finds like google does. + // Note: if you try to look at this attribute, yo MUST use getAttribute since $dom->x:y will fail the php syntax check. +// Notice the \[ starting the attbute? and the @? following? This implies that an attribute can begin with an @ sign that is not captured. +// This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression. +// farther study is required to determine of this should be documented or removed. +// $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; + $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; + preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER); + if (is_object($debugObject)) {$debugObject->debugLog(2, "Matches Array: ", $matches);} + + $selectors = array(); + $result = array(); + //print_r($matches); + + foreach ($matches as $m) { + $m[0] = trim($m[0]); + if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; + // for browser generated xpath + if ($m[1]==='tbody') continue; + + list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); + if (!empty($m[2])) {$key='id'; $val=$m[2];} + if (!empty($m[3])) {$key='class'; $val=$m[3];} + if (!empty($m[4])) {$key=$m[4];} + if (!empty($m[5])) {$exp=$m[5];} + if (!empty($m[6])) {$val=$m[6];} + + // convert to lowercase + if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);} + //elements that do NOT have the specified attribute + if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;} + + $result[] = array($tag, $key, $val, $exp, $no_key); + if (trim($m[7])===',') { + $selectors[] = $result; + $result = array(); + } + } + if (count($result)>0) + $selectors[] = $result; + return $selectors; + } + + function __get($name) { + if (isset($this->attr[$name])) + { + return $this->convert_text($this->attr[$name]); + } + switch ($name) { + case 'outertext': return $this->outertext(); + case 'innertext': return $this->innertext(); + case 'plaintext': return $this->text(); + case 'xmltext': return $this->xmltext(); + default: return array_key_exists($name, $this->attr); + } + } + + function __set($name, $value) { + switch ($name) { + case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; + case 'innertext': + if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value; + return $this->_[HDOM_INFO_INNER] = $value; + } + if (!isset($this->attr[$name])) { + $this->_[HDOM_INFO_SPACE][] = array(' ', '', ''); + $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE; + } + $this->attr[$name] = $value; + } + + function __isset($name) { + switch ($name) { + case 'outertext': return true; + case 'innertext': return true; + case 'plaintext': return true; + } + //no value attr: nowrap, checked selected... + return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]); + } + + function __unset($name) { + if (isset($this->attr[$name])) + unset($this->attr[$name]); + } + + // PaperG - Function to convert the text from one character set to another if the two sets are not the same. + function convert_text($text) + { + global $debugObject; + if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} + + $converted_text = $text; + + $sourceCharset = ""; + $targetCharset = ""; + + if ($this->dom) + { + $sourceCharset = strtoupper($this->dom->_charset); + $targetCharset = strtoupper($this->dom->_target_charset); + } + if (is_object($debugObject)) {$debugObject->debugLog(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);} + + if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0)) + { + // Check if the reported encoding could have been incorrect and the text is actually already UTF-8 + if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text))) + { + $converted_text = $text; + } + else + { + $converted_text = iconv($sourceCharset, $targetCharset, $text); + } + } + + // Lets make sure that we don't have that silly BOM issue with any of the utf-8 text we output. + if ($targetCharset == 'UTF-8') + { + if (substr($converted_text, 0, 3) == "\xef\xbb\xbf") + { + $converted_text = substr($converted_text, 3); + } + if (substr($converted_text, -3) == "\xef\xbb\xbf") + { + $converted_text = substr($converted_text, 0, -3); + } + } + + return $converted_text; + } + + /** + * Returns true if $string is valid UTF-8 and false otherwise. + * + * @param mixed $str String to be tested + * @return boolean + */ + static function is_utf8($str) + { + $c=0; $b=0; + $bits=0; + $len=strlen($str); + for($i=0; $i<$len; $i++) + { + $c=ord($str[$i]); + if($c > 128) + { + if(($c >= 254)) return false; + elseif($c >= 252) $bits=6; + elseif($c >= 248) $bits=5; + elseif($c >= 240) $bits=4; + elseif($c >= 224) $bits=3; + elseif($c >= 192) $bits=2; + else return false; + if(($i+$bits) > $len) return false; + while($bits > 1) + { + $i++; + $b=ord($str[$i]); + if($b < 128 || $b > 191) return false; + $bits--; + } + } + } + return true; + } + /* + function is_utf8($string) + { + //this is buggy + return (utf8_encode(utf8_decode($string)) == $string); + } + */ + + /** + * Function to try a few tricks to determine the displayed size of an img on the page. + * NOTE: This will ONLY work on an IMG tag. Returns FALSE on all other tag types. + * + * @author John Schlick + * @version April 19 2012 + * @return array an array containing the 'height' and 'width' of the image on the page or -1 if we can't figure it out. + */ + function get_display_size() + { + global $debugObject; + + $width = -1; + $height = -1; + + if ($this->tag !== 'img') + { + return false; + } + + // See if there is aheight or width attribute in the tag itself. + if (isset($this->attr['width'])) + { + $width = $this->attr['width']; + } + + if (isset($this->attr['height'])) + { + $height = $this->attr['height']; + } + + // Now look for an inline style. + if (isset($this->attr['style'])) + { + // Thanks to user gnarf from stackoverflow for this regular expression. + $attributes = array(); + preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER); + foreach ($matches as $match) { + $attributes[$match[1]] = $match[2]; + } + + // If there is a width in the style attributes: + if (isset($attributes['width']) && $width == -1) + { + // check that the last two characters are px (pixels) + if (strtolower(substr($attributes['width'], -2)) == 'px') + { + $proposed_width = substr($attributes['width'], 0, -2); + // Now make sure that it's an integer and not something stupid. + if (filter_var($proposed_width, FILTER_VALIDATE_INT)) + { + $width = $proposed_width; + } + } + } + + // If there is a width in the style attributes: + if (isset($attributes['height']) && $height == -1) + { + // check that the last two characters are px (pixels) + if (strtolower(substr($attributes['height'], -2)) == 'px') + { + $proposed_height = substr($attributes['height'], 0, -2); + // Now make sure that it's an integer and not something stupid. + if (filter_var($proposed_height, FILTER_VALIDATE_INT)) + { + $height = $proposed_height; + } + } + } + + } + + // Future enhancement: + // Look in the tag to see if there is a class or id specified that has a height or width attribute to it. + + // Far future enhancement + // Look at all the parent tags of this image to see if they specify a class or id that has an img selector that specifies a height or width + // Note that in this case, the class or id will have the img subselector for it to apply to the image. + + // ridiculously far future development + // If the class or id is specified in a SEPARATE css file thats not on the page, go get it and do what we were just doing for the ones on the page. + + $result = array('height' => $height, + 'width' => $width); + return $result; + } + + // camel naming conventions + function getAllAttributes() {return $this->attr;} + function getAttribute($name) {return $this->__get($name);} + function setAttribute($name, $value) {$this->__set($name, $value);} + function hasAttribute($name) {return $this->__isset($name);} + function removeAttribute($name) {$this->__set($name, null);} + function getElementById($id) {return $this->find("#$id", 0);} + function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);} + function getElementByTagName($name) {return $this->find($name, 0);} + function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);} + function parentNode() {return $this->parent();} + function childNodes($idx=-1) {return $this->children($idx);} + function firstChild() {return $this->first_child();} + function lastChild() {return $this->last_child();} + function nextSibling() {return $this->next_sibling();} + function previousSibling() {return $this->prev_sibling();} + function hasChildNodes() {return $this->has_child();} + function nodeName() {return $this->tag;} + function appendChild($node) {$node->parent($this); return $node;} + +} + +/** + * simple html dom parser + * Paperg - in the find routine: allow us to specify that we want case insensitive testing of the value of the selector. + * Paperg - change $size from protected to public so we can easily access it + * Paperg - added ForceTagsClosed in the constructor which tells us whether we trust the html or not. Default is to NOT trust it. + * + * @package PlaceLocalInclude + */ +class simple_html_dom +{ + public $root = null; + public $nodes = array(); + public $callback = null; + public $lowercase = false; + // Used to keep track of how large the text was when we started. + public $original_size; + public $size; + protected $pos; + protected $doc; + protected $char; + protected $cursor; + protected $parent; + protected $noise = array(); + protected $token_blank = " \t\r\n"; + protected $token_equal = ' =/>'; + protected $token_slash = " />\r\n\t"; + protected $token_attr = ' >'; + // Note that this is referenced by a child node, and so it needs to be public for that node to see this information. + public $_charset = ''; + public $_target_charset = ''; + protected $default_br_text = ""; + public $default_span_text = ""; + + // use isset instead of in_array, performance boost about 30%... + protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1); + protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1); + // Known sourceforge issue #2977341 + // B tags that are not closed cause us to return everything to the end of the document. + protected $optional_closing_tags = array( + 'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1), + 'th'=>array('th'=>1), + 'td'=>array('td'=>1), + 'li'=>array('li'=>1), + 'dt'=>array('dt'=>1, 'dd'=>1), + 'dd'=>array('dd'=>1, 'dt'=>1), + 'dl'=>array('dd'=>1, 'dt'=>1), + 'p'=>array('p'=>1), + 'nobr'=>array('nobr'=>1), + 'b'=>array('b'=>1), + 'option'=>array('option'=>1), + ); + + function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) + { + if ($str) + { + if (preg_match("/^http:\/\//i",$str) || is_file($str)) + { + $this->load_file($str); + } + else + { + $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText); + } + } + // Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html. + if (!$forceTagsClosed) { + $this->optional_closing_array=array(); + } + $this->_target_charset = $target_charset; + } + + function __destruct() + { + $this->clear(); + } + + // load html from string + function load($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) + { + global $debugObject; + + // prepare + $this->prepare($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText); + // strip out comments + $this->remove_noise("''is"); + // strip out cdata + $this->remove_noise("''is", true); + // Per sourceforge http://sourceforge.net/tracker/?func=detail&aid=2949097&group_id=218559&atid=1044037 + // Script tags removal now preceeds style tag removal. + // strip out \ No newline at end of file diff --git a/templates/gallery_rateit_default.xhtml b/templates/gallery_rateit_default.xhtml new file mode 100644 index 0000000..d2c9d81 --- /dev/null +++ b/templates/gallery_rateit_default.xhtml @@ -0,0 +1,50 @@ + +
    + body as $class=>$row): ?> + + addImage): ?> +
  • +
    margin): ?> style="margin; ?>"> + href): ?> + attributes; ?> title="alt; ?>">imgSize; ?> alt="alt; ?>" /> + + imgSize; ?> alt="alt; ?>" /> + + caption): ?> +
    caption; ?>
    + +
    + +
    + arrRating[$col->singleSRC]['showBefore']) : ?> +
    arrRating[$col->singleSRC]['description']; ?>
    + +
    +
    +
    +
    + arrRating[$col->singleSRC]['showAfter']) : ?> +
    arrRating[$col->singleSRC]['description']; ?>
    + +
    + +
  • + + + +
+ diff --git a/templates/j_colorbox_rateit.html5 b/templates/j_colorbox_rateit.html5 new file mode 100644 index 0000000..16a2cbb --- /dev/null +++ b/templates/j_colorbox_rateit.html5 @@ -0,0 +1,27 @@ + + + + diff --git a/templates/j_colorbox_rateit.xhtml b/templates/j_colorbox_rateit.xhtml new file mode 100644 index 0000000..cc6854e --- /dev/null +++ b/templates/j_colorbox_rateit.xhtml @@ -0,0 +1,26 @@ + + + + diff --git a/templates/mod_article_list_rateit.html5 b/templates/mod_article_list_rateit.html5 new file mode 100644 index 0000000..c423a62 --- /dev/null +++ b/templates/mod_article_list_rateit.html5 @@ -0,0 +1,48 @@ + +
cssID; ?>style): ?> style="style; ?>"> + + headline): ?> + <hl; ?>>headline; ?>hl; ?>> + + +
    + articles as $article): ?> +
  • + + +
    + +
    + +
    +
    +
    +
    + +
    + +
    + + + + + +
    + +
    + +
    +
    +
    +
    + +
    + +
    + + +
  • + +
+ +
diff --git a/templates/mod_article_list_rateit.xhtml b/templates/mod_article_list_rateit.xhtml new file mode 100644 index 0000000..374a7ef --- /dev/null +++ b/templates/mod_article_list_rateit.xhtml @@ -0,0 +1,46 @@ + +
cssID; ?>style): ?> style="style; ?>"> + + headline): ?> + <hl; ?>>headline; ?>hl; ?>> + + +
    + articles as $article): ?> + + +
    + +
    + +
    +
    +
    +
    + +
    + +
    + + +
  • + + +
    + +
    + +
    +
    +
    +
    + +
    + +
    + + + +
+ +
diff --git a/templates/mod_article_rateit_default_microdata_teaser.html5 b/templates/mod_article_rateit_default_microdata_teaser.html5 new file mode 100644 index 0000000..b7abe2b --- /dev/null +++ b/templates/mod_article_rateit_default_microdata_teaser.html5 @@ -0,0 +1,64 @@ +
cssID; ?>style): ?> style="style; ?>"> + + rateit_rating_before): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
+ +

headline; ?>

+ +
+ teaser; ?> +

more; ?>

+
+ +
+ + rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
diff --git a/templates/mod_article_rateit_default_microdata_teaser.xhtml b/templates/mod_article_rateit_default_microdata_teaser.xhtml new file mode 100644 index 0000000..c1d39ea --- /dev/null +++ b/templates/mod_article_rateit_default_microdata_teaser.xhtml @@ -0,0 +1,64 @@ +
cssID; ?>style): ?> style="style; ?>"> + + rateit_rating_before): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
+ +

headline; ?>

+ +
+ teaser; ?> +

more; ?>

+
+ +
+ + rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
diff --git a/templates/mod_article_rateit_default_teaser.html5 b/templates/mod_article_rateit_default_teaser.html5 new file mode 100644 index 0000000..2cfc021 --- /dev/null +++ b/templates/mod_article_rateit_default_teaser.html5 @@ -0,0 +1,48 @@ +
cssID; ?>style): ?> style="style; ?>"> + + rateit_rating_before): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
+ +

headline; ?>

+ +
+ teaser; ?> +

more; ?>

+
+ +
+ + rateit_rating_after): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
diff --git a/templates/mod_article_rateit_default_teaser.xhtml b/templates/mod_article_rateit_default_teaser.xhtml new file mode 100644 index 0000000..ac1e91f --- /dev/null +++ b/templates/mod_article_rateit_default_teaser.xhtml @@ -0,0 +1,48 @@ +
cssID; ?>style): ?> style="style; ?>"> + + rateit_rating_before): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
+ +

headline; ?>

+ +
+ teaser; ?> +

more; ?>

+
+ +
+ + rateit_rating_after): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
diff --git a/templates/mod_rateit_top_ratings.html5 b/templates/mod_rateit_top_ratings.html5 new file mode 100644 index 0000000..9c7d83c --- /dev/null +++ b/templates/mod_rateit_top_ratings.html5 @@ -0,0 +1,25 @@ + +
cssID; ?>style): ?> style="style; ?>"> + + headline): ?> + <hl; ?>>headline; ?>hl; ?>> + + +
    + arrRatings as $rating): ?> +
  • + +
    title; ?>
    +
    +
    +
    +
    +
    +
    description; ?>
    +
    + +
  • + +
+ +
diff --git a/templates/mod_rateit_top_ratings.xhtml b/templates/mod_rateit_top_ratings.xhtml new file mode 100644 index 0000000..9c7d83c --- /dev/null +++ b/templates/mod_rateit_top_ratings.xhtml @@ -0,0 +1,25 @@ + +
cssID; ?>style): ?> style="style; ?>"> + + headline): ?> + <hl; ?>>headline; ?>hl; ?>> + + +
    + arrRatings as $rating): ?> +
  • + +
    title; ?>
    +
    +
    +
    +
    +
    +
    description; ?>
    +
    + +
  • + +
+ +
diff --git a/templates/moo_mediabox_rateit.html5 b/templates/moo_mediabox_rateit.html5 new file mode 100644 index 0000000..d745013 --- /dev/null +++ b/templates/moo_mediabox_rateit.html5 @@ -0,0 +1,32 @@ + + + + diff --git a/templates/moo_mediabox_rateit.xhtml b/templates/moo_mediabox_rateit.xhtml new file mode 100644 index 0000000..cd06cb4 --- /dev/null +++ b/templates/moo_mediabox_rateit.xhtml @@ -0,0 +1,33 @@ + + + + diff --git a/templates/news_full_rateit.html5 b/templates/news_full_rateit.html5 new file mode 100644 index 0000000..d490948 --- /dev/null +++ b/templates/news_full_rateit.html5 @@ -0,0 +1,90 @@ + +rateit_rating_before): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
+ +

newsHeadline; ?>

+hasMetaFields): ?> + +

author; ?> commentCount; ?>

+ +hasSubHeadline): ?> + +

subHeadline; ?>

+ + +
+addBefore): ?> + +text; ?> + +addImage): ?> + +
margin || $this->float): ?> style="margin . $this->float); ?>"> +href): ?> +attributes; ?> title="alt; ?>"> + +imgSize; ?> alt="alt; ?>"> +href): ?> + + +caption): ?> +
caption; ?>
+ +
+ +addBefore): ?> + +text; ?> + + +
+enclosure): ?> + +
+enclosure as $enclosure): ?> +

<?php echo $enclosure['mime']; ?> ()

+ +
+ + +
+rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_full_rateit.xhtml b/templates/news_full_rateit.xhtml new file mode 100644 index 0000000..4cb36c4 --- /dev/null +++ b/templates/news_full_rateit.xhtml @@ -0,0 +1,90 @@ + +rateit_rating_before): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
+ +

newsHeadline; ?>

+hasMetaFields): ?> + +

date; ?> author; ?> commentCount; ?>

+ +hasSubHeadline): ?> + +

subHeadline; ?>

+ + +
+addBefore): ?> + +text; ?> + +addImage): ?> + +
margin || $this->float): ?> style="margin . $this->float); ?>"> +href): ?> +attributes; ?> title="alt; ?>"> + +imgSize; ?> alt="alt; ?>" /> +href): ?> + + +caption): ?> +
caption; ?>
+ +
+ +addBefore): ?> + +text; ?> + + +
+enclosure): ?> + +
+enclosure as $enclosure): ?> +

<?php echo $enclosure['mime']; ?> ()

+ +
+ + +
+rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_full_rateit_microdata.html5 b/templates/news_full_rateit_microdata.html5 new file mode 100644 index 0000000..36f3f20 --- /dev/null +++ b/templates/news_full_rateit_microdata.html5 @@ -0,0 +1,99 @@ + +rateit_rating_before): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
+ +

newsHeadline; ?>

+hasMetaFields): ?> + +

author; ?> commentCount; ?>

+ +hasSubHeadline): ?> + +

subHeadline; ?>

+ + +
+addBefore): ?> + +text; ?> + +addImage): ?> + +
margin || $this->float): ?> style="margin . $this->float); ?>"> +href): ?> +attributes; ?> title="alt; ?>"> + +imgSize; ?> alt="alt; ?>"> +href): ?> + + +caption): ?> +
caption; ?>
+ +
+ +addBefore): ?> + +text; ?> + + +
+enclosure): ?> + +
+enclosure as $enclosure): ?> +

<?php echo $enclosure['mime']; ?> ()

+ +
+ + +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_full_rateit_microdata.xhtml b/templates/news_full_rateit_microdata.xhtml new file mode 100644 index 0000000..f35d2e2 --- /dev/null +++ b/templates/news_full_rateit_microdata.xhtml @@ -0,0 +1,99 @@ + +rateit_rating_before): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
+ +

newsHeadline; ?>

+hasMetaFields): ?> + +

date; ?> author; ?> commentCount; ?>

+ +hasSubHeadline): ?> + +

subHeadline; ?>

+ + +
+addBefore): ?> + +text; ?> + +addImage): ?> + +
margin || $this->float): ?> style="margin . $this->float); ?>"> +href): ?> +attributes; ?> title="alt; ?>"> + +imgSize; ?> alt="alt; ?>" /> +href): ?> + + +caption): ?> +
caption; ?>
+ +
+ +addBefore): ?> + +text; ?> + + +
+enclosure): ?> + +
+enclosure as $enclosure): ?> +

<?php echo $enclosure['mime']; ?> ()

+ +
+ + +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_latest_rateit.html5 b/templates/news_latest_rateit.html5 new file mode 100644 index 0000000..d7d64e6 --- /dev/null +++ b/templates/news_latest_rateit.html5 @@ -0,0 +1,69 @@ + +rateit_rating_before): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
+hasMetaFields): ?> +

author; ?> commentCount; ?>

+ +addImage): ?> +
margin || $this->float): ?> style="margin . $this->float); ?>"> +href): ?> +attributes; ?> title="alt; ?>"> + +imgSize; ?> alt="alt; ?>"> +href): ?> + + +caption): ?> +
caption; ?>
+ +
+ +

text ? $this->linkHeadline : $this->newsHeadline; ?>

+
+teaser; ?> +
+text): ?> +

more; ?>

+ +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_latest_rateit.xhtml b/templates/news_latest_rateit.xhtml new file mode 100644 index 0000000..80ace42 --- /dev/null +++ b/templates/news_latest_rateit.xhtml @@ -0,0 +1,69 @@ + +rateit_rating_before): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
+hasMetaFields): ?> +

date; ?> author; ?> commentCount; ?>

+ +addImage): ?> +
margin || $this->float): ?> style="margin . $this->float); ?>"> +href): ?> +attributes; ?> title="alt; ?>"> + +imgSize; ?> alt="alt; ?>" /> +href): ?> + + +caption): ?> +
caption; ?>
+ +
+ +

text ? $this->linkHeadline : $this->newsHeadline; ?>

+
+teaser; ?> +
+text): ?> +

more; ?>

+ +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_latest_rateit_microdata.html5 b/templates/news_latest_rateit_microdata.html5 new file mode 100644 index 0000000..876c8c7 --- /dev/null +++ b/templates/news_latest_rateit_microdata.html5 @@ -0,0 +1,77 @@ + +rateit_rating_before): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
+hasMetaFields): ?> +

author; ?> commentCount; ?>

+ +addImage): ?> +
margin || $this->float): ?> style="margin . $this->float); ?>"> +href): ?> +attributes; ?> title="alt; ?>"> + +imgSize; ?> alt="alt; ?>"> +href): ?> + + +caption): ?> +
caption; ?>
+ +
+ +

text ? $this->linkHeadline : $this->newsHeadline; ?>

+
+teaser; ?> +
+text): ?> +

more; ?>

+ +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_latest_rateit_microdata.xhtml b/templates/news_latest_rateit_microdata.xhtml new file mode 100644 index 0000000..297270a --- /dev/null +++ b/templates/news_latest_rateit_microdata.xhtml @@ -0,0 +1,77 @@ + +rateit_rating_before): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
+hasMetaFields): ?> +

date; ?> author; ?> commentCount; ?>

+ +addImage): ?> +
margin || $this->float): ?> style="margin . $this->float); ?>"> +href): ?> +attributes; ?> title="alt; ?>"> + +imgSize; ?> alt="alt; ?>" /> +href): ?> + + +caption): ?> +
caption; ?>
+ +
+ +

text ? $this->linkHeadline : $this->newsHeadline; ?>

+
+teaser; ?> +
+text): ?> +

more; ?>

+ +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_short_rateit.html5 b/templates/news_short_rateit.html5 new file mode 100644 index 0000000..600bb21 --- /dev/null +++ b/templates/news_short_rateit.html5 @@ -0,0 +1,55 @@ + +rateit_rating_before): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
+hasMetaFields): ?> +

author; ?> commentCount; ?>

+ +

text ? $this->linkHeadline : $this->newsHeadline; ?>

+
+teaser; ?> +
+text): ?> +

more; ?>

+ +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_short_rateit.xhtml b/templates/news_short_rateit.xhtml new file mode 100644 index 0000000..086a743 --- /dev/null +++ b/templates/news_short_rateit.xhtml @@ -0,0 +1,55 @@ + +rateit_rating_before): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
+hasMetaFields): ?> +

date; ?> author; ?> commentCount; ?>

+ +

text ? $this->linkHeadline : $this->newsHeadline; ?>

+
+teaser; ?> +
+text): ?> +

more; ?>

+ +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_short_rateit_microdata.html5 b/templates/news_short_rateit_microdata.html5 new file mode 100644 index 0000000..2f875f5 --- /dev/null +++ b/templates/news_short_rateit_microdata.html5 @@ -0,0 +1,63 @@ + +rateit_rating_before): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
+hasMetaFields): ?> +

author; ?> commentCount; ?>

+ +

text ? $this->linkHeadline : $this->newsHeadline; ?>

+
+teaser; ?> +
+text): ?> +

more; ?>

+ +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_short_rateit_microdata.xhtml b/templates/news_short_rateit_microdata.xhtml new file mode 100644 index 0000000..9a3fab6 --- /dev/null +++ b/templates/news_short_rateit_microdata.xhtml @@ -0,0 +1,63 @@ + +rateit_rating_before): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
+hasMetaFields): ?> +

date; ?> author; ?> commentCount; ?>

+ +

text ? $this->linkHeadline : $this->newsHeadline; ?>

+
+teaser; ?> +
+text): ?> +

more; ?>

+ +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_simple_rateit.html5 b/templates/news_simple_rateit.html5 new file mode 100644 index 0000000..222b8b5 --- /dev/null +++ b/templates/news_simple_rateit.html5 @@ -0,0 +1,38 @@ + +rateit_rating_before): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
+date): ?> linkHeadline; ?> +
+ +rateit_rating_after): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + diff --git a/templates/news_simple_rateit.xhtml b/templates/news_simple_rateit.xhtml new file mode 100644 index 0000000..13ed041 --- /dev/null +++ b/templates/news_simple_rateit.xhtml @@ -0,0 +1,38 @@ + +rateit_rating_before): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + + +
+date): ?>date; ?> linkHeadline; ?> +
+ +rateit_rating_after): ?> + +
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ + diff --git a/templates/news_simple_rateit_microdata.html5 b/templates/news_simple_rateit_microdata.html5 new file mode 100644 index 0000000..3f4cee5 --- /dev/null +++ b/templates/news_simple_rateit_microdata.html5 @@ -0,0 +1,54 @@ + +rateit_rating_before): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
+date): ?> linkHeadline; ?> +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/news_simple_rateit_microdata.xhtml b/templates/news_simple_rateit_microdata.xhtml new file mode 100644 index 0000000..c26b1b2 --- /dev/null +++ b/templates/news_simple_rateit_microdata.xhtml @@ -0,0 +1,54 @@ + +rateit_rating_before): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + + +
+date): ?>date; ?> linkHeadline; ?> +
+ +rateit_rating_after): ?> + +
+
+ showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ + diff --git a/templates/rateit_default.html5 b/templates/rateit_default.html5 new file mode 100644 index 0000000..155a0bc --- /dev/null +++ b/templates/rateit_default.html5 @@ -0,0 +1,14 @@ + +
cssID; ?>style): ?> style="style; ?>"> + showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ \ No newline at end of file diff --git a/templates/rateit_default.xhtml b/templates/rateit_default.xhtml new file mode 100644 index 0000000..155a0bc --- /dev/null +++ b/templates/rateit_default.xhtml @@ -0,0 +1,14 @@ + +
cssID; ?>style): ?> style="style; ?>"> + showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ \ No newline at end of file diff --git a/templates/rateit_microdata.html5 b/templates/rateit_microdata.html5 new file mode 100644 index 0000000..dc1cf04 --- /dev/null +++ b/templates/rateit_microdata.html5 @@ -0,0 +1,22 @@ + +
+
cssID; ?>style): ?> style="style; ?>"> + showBefore) : ?> +
description; ?>
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+ +
+ itemreviewed; ?> + + actRating; ?> + maxRating; ?> + + votes; ?> +
+ \ No newline at end of file diff --git a/templates/rateit_microdata.xhtml b/templates/rateit_microdata.xhtml new file mode 100644 index 0000000..ae73835 --- /dev/null +++ b/templates/rateit_microdata.xhtml @@ -0,0 +1,16 @@ + +
cssID; ?>style): ?> style="style; ?>"> + showBefore) : ?> +
description; ?>
+
Microdata-Template ist bei XHTML nicht verfügbar. Bitte stellen Sie auf HTML5 um oder wechseln Sie das verwendete Template!
+ +
+
+
+
+ showAfter) : ?> +
description; ?>
+
Microdata-Template ist bei XHTML nicht verfügbar. Bitte stellen Sie auf HTML5 um oder wechseln Sie das verwendete Template!
+ +
+ \ No newline at end of file diff --git a/templates/rateitbe_ratinglist.html5 b/templates/rateitbe_ratinglist.html5 new file mode 100644 index 0000000..03f8a6a --- /dev/null +++ b/templates/rateitbe_ratinglist.html5 @@ -0,0 +1,182 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @version 3.1.0 stable + * @license GNU/LGPL + * @filesource + */ + +$rateit = &$this->rateit; +$theme = &$rateit->theme; +$text = &$GLOBALS['TL_LANG']['tl_rateit']; +$type_options = &$GLOBALS['TL_LANG']['tl_rateit_type_options']; +$active_options = &$GLOBALS['TL_LANG']['tl_rateit_active_options']; +$order_options = &$GLOBALS['TL_LANG']['tl_rateit_order_options']; + +?> + +
+ +
+
+ + + +
+ +
+: + + +
+ +
+ +
+
+ +
+ +
+ +
+: + +
+ + + +
+: + +
+ +
+ +
+ + + +
+
+ +
+
+ + +ratingitems) < 1): ?> + +

+ +
+ +
+
+
+ratingitems as $rating): ?> + + + + + + + + + + + + + + + + + + + + + + + +
 title; ?> createListButton('info', $rating->viewLink, $text['showdetails']); ?>
title; ?>typ]; ?>
parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $rating->createdat); ?>active]; ?>
rating), $rating->stars, $rating->totalRatings); ?>
  
+ +
+
+ +
+
+ + +
+ +
+ + diff --git a/templates/rateitbe_ratingview.html5 b/templates/rateitbe_ratingview.html5 new file mode 100644 index 0000000..8f24218 --- /dev/null +++ b/templates/rateitbe_ratingview.html5 @@ -0,0 +1,199 @@ +. + * + * PHP version 5 + * @copyright cgo IT, 2013 + * @author Carsten Götzinger (info@cgo-it.de) + * @package rateit + * @version 3.1.0 stable + * @license GNU/LGPL + * @filesource + */ + +$rateit = &$this->rateit; +$theme = &$rateit->theme; +$text = &$GLOBALS['TL_LANG']['tl_rateit']; +$type_options = &$GLOBALS['TL_LANG']['tl_rateit_type_options']; +$active_options = &$GLOBALS['TL_LANG']['tl_rateit_active_options']; +$rating = &$rateit->ratingitems[0]; +$label = $GLOBALS['TL_CONFIG']['rating_type'] == 'hearts' ? $GLOBALS['TL_LANG']['rateit']['heart'] : $GLOBALS['TL_LANG']['rateit']['star']; +$labels = $GLOBALS['TL_CONFIG']['rating_type'] == 'hearts' ? $GLOBALS['TL_LANG']['rateit']['hearts'] : $GLOBALS['TL_LANG']['rateit']['stars']; + +?> + +
+ + + + + +
+
+ + + +
+ +
+ +
+ +
+ +
+: + +
+ +
+ +
+ +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
title; ?>
 
title; ?>typ]; ?>
parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $rating->createdat); ?>active]; ?>
rating), $rating->stars, $rating->totalRatings); ?>
  
 
+ + + + + +
+
 
+ratings) < 1): ?> +

+ + + + + + + + + ratings as $r) : ?> + + + + + + + +
ip; ?>member; ?>
rating), $rating->stars).' '.$labels; ?>
parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $r->createdat); ?>
+ +
+
+ +