Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Accessit {
- private static $_instance;
- private static $DIV_NAMES = array();
- private function __construct($xoopsDB)
- {
- $this->xoopsDB = $xoopsDB;
- }
- private function __clone () {}
- public static function getInstance($xoopsDB)
- {
- if (!(self::$_instance instanceof self)) self::$_instance = new self($xoopsDB);
- return self::$_instance;
- }
- public function retDivNames()
- {
- $this->DIV_NAMES = array();
- $TMP = array();
- $table = $this->xoopsDB->prefix('tplsource');
- $sql = "SELECT tpl_source FROM " . $table . ";";
- $result = $this->xoopsDB->queryF($sql);
- while($row = $this->xoopsDB->fetchArray($result))
- {
- foreach($row as $value)
- {
- $TMP[] = $value;
- }
- }
- foreach($TMP as $var)
- {
- $html = str_get_html(($var));
- foreach($html->find('div') as $element)
- if(is_string($element->id))
- if(stripos($element->id, "<"))
- {
- $this->DIV_NAMES[] = substr($element->id, 0, stripos($element->id, "<"));
- }else
- {
- $this->DIV_NAMES[] = $element->id;
- }
- }
- $this->DIV_NAMES = array_unique($this->DIV_NAMES);
- sort($this->DIV_NAMES);
- // insertion of the div names in the accessit table
- $table = $this->xoopsDB->prefix('accessit');
- foreach($this->DIV_NAMES as $value)
- {
- $sql = 'SELECT id FROM ' . $table . ' WHERE div_name=\'' . $value . '\';';
- $result = $this->xoopsDB->queryF($sql);
- if(!$this->xoopsDB->fetchArray($result))
- {
- $sql = 'INSERT INTO ' . $table . ' (div_name) VALUES (\'' . $value . '\');';
- $this->xoopsDB->queryF($sql);
- }
- }
- return $this->DIV_NAMES;
- }
- public function getDivNamesFromDb()
- {
- $table = $this->xoopsDB->prefix('accessit');
- $sql = 'SELECT div_name, role FROM ' . $table . ';';
- $result = $this->xoopsDB->queryF($sql);
- while($row = $this->xoopsDB->fetchArray($result))
- {
- $this->DIV_NAMES[$row['div_name']] = $row['role'];
- }
- return $this->DIV_NAMES;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement