예제 #1
0
 /**
  * @param BasePlugin $plugin
  * @return bool
  */
 public function setNewPluginInfo(BasePlugin $plugin)
 {
     $affectedRows = craft()->db->createCommand()->update('plugins', array('version' => $plugin->getVersion()), array('class' => $plugin->getClassHandle()));
     return (bool) $affectedRows;
 }
예제 #2
0
 /**
  * Returns whether a plugin class exists.
  *
  * @param BasePlugin $plugin         The plugin.
  * @param string     $classSubfolder The subfolder to search.
  * @param string     $class          The class suffix we’re looking for.
  * @param bool       $autoload       Whether the found class should be imported for the autoloader.
  *
  * @return bool Whether the class exists.
  */
 public function doesPluginClassExist(BasePlugin $plugin, $classSubfolder, $class, $autoload = true)
 {
     $pluginFolder = mb_strtolower($plugin->getClassHandle());
     $classPath = craft()->path->getPluginsPath() . $pluginFolder . '/' . $classSubfolder . '/' . $class . '.php';
     if (IOHelper::fileExists($classPath)) {
         if ($autoload) {
             Craft::import("plugins.{$pluginFolder}.{$classSubfolder}.{$class}");
         }
         return true;
     } else {
         return false;
     }
 }
예제 #3
0
 /**
  * Finds and imports all of the supported component classes for a given plugin.
  *
  * @access private
  * @param BasePlugin $plugin
  */
 private function _importPluginComponents(BasePlugin $plugin)
 {
     $pluginHandle = $plugin->getClassHandle();
     $lcPluginHandle = strtolower($plugin->getClassHandle());
     $pluginFolder = craft()->path->getPluginsPath() . $lcPluginHandle . '/';
     foreach ($this->componentTypes as $type => $typeInfo) {
         $folder = $pluginFolder . $typeInfo['subfolder'];
         if (IOHelper::folderExists($folder)) {
             // See if it has any files in ClassName*Suffix.php format.
             $filter = $pluginHandle . '(_.+)?' . $typeInfo['suffix'] . '\\.php$';
             $files = IOHelper::getFolderContents($folder, false, $filter);
             if ($files) {
                 foreach ($files as $file) {
                     // Get the class name
                     $class = IOHelper::getFileName($file, false);
                     // Import the class.
                     Craft::import('plugins.' . $lcPluginHandle . '.' . $typeInfo['subfolder'] . '.' . $class);
                     // Remember it
                     $this->_pluginComponentClasses[$type][$pluginHandle][] = $class;
                 }
             }
         }
     }
 }