Ejemplo n.º 1
0
 public function deleteTables()
 {
     if (!MFile::exists($filename = MPATH_WP_PLG . '/' . $this->context . '/admin/uninstall.sql')) {
         return null;
     }
     $db = MFactory::getDbo();
     $file_content = file($filename);
     if (empty($file_content)) {
         return null;
     }
     $query = '';
     foreach ($file_content as $sql_line) {
         $tsl = trim($sql_line);
         if ($tsl != '' && (strpos($tsl, '--') != 0 || strpos($tsl, '--') != 1) && substr($tsl, 0, 1) != '#') {
             $query .= $sql_line;
             if (preg_match('/;\\s*$/', $sql_line)) {
                 $db->setQuery($query);
                 $db->query();
                 $query = '';
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * 
  *
  * @return bool
  */
 public static function fileExists($filePath)
 {
     MAssertTypes('string', $filePath);
     $file = new MFile(S($filePath));
     return $file->exists();
 }
Ejemplo n.º 3
0
 public function menu()
 {
     MFactory::getLanguage()->load('com_' . $this->context, MPATH_ADMINISTRATOR);
     $title = $this->title;
     if (empty($this->title)) {
         $title = MText::_('COM_' . strtoupper($this->context));
     }
     mimport('framework.filesystem.file');
     $img = '';
     if (MFile::exists(MPATH_WP_PLG . '/' . $this->context . '/admin/assets/images/icon-16-' . $this->context . '.png')) {
         $img = plugins_url($this->context . '/admin/assets/images/icon-16-' . $this->context . '.png');
     }
     add_menu_page($title, $title, 'manage_options', $this->context, array($this, 'display'), $img, $this->menu_id);
     if ($this->has_config == true) {
         add_submenu_page($this->context, MText::_('COM_' . strtoupper($this->context) . '_CPANEL_CONFIGURATION'), MText::_('COM_' . strtoupper($this->context) . '_CPANEL_CONFIGURATION'), 'manage_options', MRoute::_('index.php?option=com_' . $this->context . '&view=config'));
     }
     $toolbar_file = MPATH_WP_PLG . '/' . $this->context . '/admin/toolbar.php';
     if (file_exists($toolbar_file)) {
         require_once $toolbar_file;
     }
     if (!empty($views)) {
         foreach ($views as $key => $val) {
             if (empty($key)) {
                 continue;
             }
             add_submenu_page($this->context, $val, $val, 'manage_options', MRoute::_('index.php?option=com_' . $this->context . $key));
         }
     }
 }
 /**
  * Parses one or more Managed Objects from inside the specified XML file
  * and inserts them into this Managed Object Context
  *
  * @param MFile $file An XML file containing the objects to be parsed
  * @param callable $callback A callback function which will be called every time a new
  * object is parsed and added into the Managed Object Context. The method signature for the
  * callback is callback(MManagedObject $object);
  *
  * @return MArray An Array containing the parsed objects
  */
 public function parseObjectsFromFile(MFile $file, callable $callback = null)
 {
     if (!$file->exists()) {
         throw new MFileNotFoundException($file->path());
     }
     $xml = simplexml_load_file($file->path()->stringValue());
     return $this->parseObjectsFromXML($xml, $callback);
 }