Exemplo n.º 1
0
 static function addTitleAndMetaTags()
 {
     global $database, $doc, $mainframe, $Itemid;
     $view = JREQUEST::getCmd('view', null);
     $catid = JREQUEST::getInt('catid', null);
     $id = JREQUEST::getInt('id', null);
     $lang = JREQUEST::getString('lang', null);
     $title = array();
     $sitename = htmlspecialchars($mainframe->getCfg('sitename'));
     if (isset($view)) {
         $view = str_replace("_", " ", $view);
         $view = ucfirst($view);
         $title[] = $view;
     }
     $s = blLittleThings::getWhereUsergroupsCondition();
     if (!isset($catid)) {
         // Parameters
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $menu = new JTableMenu($database);
             $menu->load($Itemid);
             $params = new JRegistry();
             $params->loadString($menu->params);
         } else {
             $menu = new mosMenu($database);
             $menu->load($Itemid);
             $params = new mosParameters($menu->params);
         }
         if (version_compare(JVERSION, "1.6.0", "lt")) {
             $catid = $params->get('catid');
         } else {
             if (version_compare(JVERSION, "1.6.0", "ge") && version_compare(JVERSION, "3.5.100", "lt")) {
                 $single_category_id = '';
                 // for 1.6
                 $single_category_id = $params->get('single_category');
                 if ($single_category_id > 0) {
                     $catid = $single_category_id;
                 }
             }
         }
     }
     //To get name of category
     if (isset($catid)) {
         $query = "SELECT  c.name, c.id AS catid, c.parent_id\n                    FROM #__booklibrary_main_categories AS c\n                    WHERE ({$s}) AND c.id = " . intval($catid);
         $database->setQuery($query);
         $row = null;
         $row = $database->loadObject();
         if (isset($row)) {
             $cattitle = array();
             $cattitle[] = $row->name;
             while (isset($row) && $row->parent_id > 0) {
                 $query = "SELECT  name, c.id AS catid, parent_id \n                        FROM #__booklibrary_main_categories AS c\n                        WHERE ({$s}) AND c.id = " . intval($row->parent_id);
                 $database->setQuery($query);
                 $row = $database->loadObject();
                 if (isset($row) && $row->name != '') {
                     $cattitle[] = $row->name;
                 }
             }
             $title = array_merge($title, array_reverse($cattitle));
         }
     }
     //To get Name of the book
     if (isset($id)) {
         $row = $database->loadObject();
         if (isset($row)) {
             $idtitle = array();
             $title = array_merge($title, $idtitle);
         }
     }
     $tagtitle = "";
     for ($i = 0; $i < count($title); $i++) {
         $tagtitle = trim($tagtitle) . " | " . trim($title[$i]);
     }
     $blm = "BookLibrary Manager ";
     //To set Title
     $title_tag = PHP_booklibrary::mylenStr($blm . $tagtitle, 75);
     //To set meta Description
     $metadata_description_tag = PHP_booklibrary::mylenStr($blm . $tagtitle, 200);
     //To set meta KeywordsTag
     $metadata_keywords_tag = PHP_booklibrary::mylenStr($blm . $tagtitle, 250);
     $doc->setTitle($title_tag);
     $doc->setMetaData('description', $metadata_description_tag);
     $doc->setMetaData('keywords', $metadata_keywords_tag);
 }
Exemplo n.º 2
0
 static function getWhereUsergroupsCondition($table_alias = "c")
 {
     if (version_compare(JVERSION, "1.6.0", "lt")) {
         global $my;
         if (!isset($my)) {
             // echo "User is logged out";
             if ($my = JFactory::getUser()) {
                 $gid = $my->gid;
             } else {
                 $gid = 0;
             }
         } else {
             $gid = $my->gid;
         }
         $usergroups_sh = array($gid, -2);
         $s = '';
         for ($i = 0; $i < count($usergroups_sh); $i++) {
             $g = $usergroups_sh[$i];
             $s .= " {$table_alias}.params LIKE '%,{$g}' or {$table_alias}.params = '{$g}' or {$table_alias}.params LIKE '{$g},%' or {$table_alias}.params LIKE '%,{$g},%' ";
             if ($i + 1 < count($usergroups_sh)) {
                 $s .= ' or ';
             }
         }
         return $s;
     } else {
         if (version_compare(JVERSION, "1.6.0", "ge") && version_compare(JVERSION, "3.5.0", "lt")) {
             $my = JFactory::getUser();
             if (isset($my->id) and $my->id != 0) {
                 $usergroups_sh = blLittleThings::getGroupsByUser($my->id, '');
             } else {
                 $usergroups_sh = array();
             }
             $usergroups_sh[] = -2;
             $s = '';
             for ($i = 0; $i < count($usergroups_sh); $i++) {
                 $g = $usergroups_sh[$i];
                 $s .= " {$table_alias}.params LIKE '%,{$g}' or {$table_alias}.params = '{$g}' or {$table_alias}.params LIKE '{$g},%' or {$table_alias}.params LIKE '%,{$g},%' ";
                 if ($i + 1 < count($usergroups_sh)) {
                     $s .= ' or ';
                 }
             }
             return $s;
         } else {
             echo "Sanity test. Error version check!";
             exit;
         }
     }
 }