저자: jason (yangjs17@yeah.net)
상속: extends Model
예제 #1
0
 /**
  * Homepage of VanillaForums.org.
  *
  * @param Gdn_Controller $sender
  */
 public function homeController_homepage_create($sender)
 {
     try {
         $AddonModel = new AddonModel();
         $Addon = $AddonModel->getSlug('vanilla-core', true);
         $sender->setData('CountDownloads', val('CountDownloads', $Addon));
         $sender->setData('Version', val('Version', $Addon));
         $sender->setData('DateUploaded', val('DateInserted', $Addon));
     } catch (Exception $ex) {
     }
     $sender->title('The most powerful custom community solution in the world');
     $sender->setData('Description', "Vanilla is forum software that powers discussions on hundreds of thousands of sites. Built for flexibility and integration, Vanilla is the best, most powerful community solution in the world.");
     $sender->Head->addTag('meta', array('name' => 'description', 'content' => $sender->data('Description')));
     $sender->clearJsFiles();
     $sender->addJsFile('jquery.js', 'vforg');
     $sender->addJsFile('easySlider1.7.js', 'vforg');
     saveToConfig('Garden.Embed.Allow', false, false);
     // Prevent JS errors
     $sender->clearCssFiles();
     $sender->addCssFile('vforg-home.css', 'vforg');
     $sender->MasterView = 'empty';
     $sender->render('index', 'home', 'vforg');
 }
예제 #2
0
 /**
  * Set the icon for an addon.
  *
  * @param int $AddonID Specified addon id.
  * @throws Exception Addon not found.
  */
 public function icon($AddonID = '')
 {
     $Session = Gdn::session();
     if (!$Session->isValid()) {
         $this->Form->addError('You must be authenticated in order to use this form.');
     }
     $Addon = $this->AddonModel->getID($AddonID);
     if (!$Addon) {
         throw notFoundException('Addon');
     }
     if ($Session->UserID != $Addon['InsertUserID']) {
         $this->permission('Addons.Addon.Manage');
     }
     $this->addModule('AddonHelpModule', 'Panel');
     $this->Form->setModel($this->AddonModel);
     $this->Form->addHidden('AddonID', $AddonID);
     if ($this->Form->authenticatedPostBack()) {
         $UploadImage = new Gdn_UploadImage();
         try {
             // Validate the upload
             $imageLocation = $UploadImage->validateUpload('Icon');
             $TargetImage = $this->saveIcon($imageLocation);
         } catch (Exception $ex) {
             $this->Form->addError($ex);
         }
         // If there were no errors, remove the old picture and insert the picture
         if ($this->Form->errorCount() == 0) {
             if ($Addon['Icon']) {
                 $UploadImage->delete($Addon['Icon']);
             }
             $this->AddonModel->save(array('AddonID' => $AddonID, 'Icon' => $TargetImage));
         }
         // If there were no problems, redirect back to the addon
         if ($this->Form->errorCount() == 0) {
             $this->RedirectUrl = Url('/addon/' . AddonModel::slug($Addon));
         }
     }
     $this->render();
 }
예제 #3
0
 /**
  * Creates addons tab ProfileController.
  *
  * @since 2.0.0
  * @package Vanilla
  *
  * @param ProfileController $Sender
  */
 public function profileController_addons_create($Sender)
 {
     $UserReference = val(0, $Sender->RequestArgs, '');
     $Username = val(1, $Sender->RequestArgs, '');
     // Tell the ProfileController what tab to load
     $Sender->getUserInfo($UserReference, $Username);
     $Sender->setTabView('Addons', 'Profile', 'Addon', 'Addons');
     $Offset = 0;
     $Limit = 100;
     $AddonModel = new AddonModel();
     $ResultSet = $AddonModel->getWhere(array('UserID' => $Sender->User->UserID), 'DateUpdated', 'desc', $Limit, $Offset);
     $Sender->setData('Addons', $ResultSet);
     $NumResults = $AddonModel->getCount(array('InsertUserID' => $Sender->User->UserID));
     // Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views
     $Sender->HandlerType = HANDLER_TYPE_NORMAL;
     // Render the ProfileController
     $Sender->render();
 }
예제 #4
0
 /**
  * Get an addon based on its slug in the following form:
  *  - AddonID[-AddonName]
  *  - AddonType-AddonKey[-Version]
  *
  * @param string|int $Slug The slug to lookup
  * @param bool $GetVersions Whether or not to add an array of versions to the result.
  * @return array
  */
 public function getSlug($slug, $getVersions = false)
 {
     if (is_numeric($slug)) {
         $addon = $this->getID($slug, false, ['GetVersions' => $getVersions]);
     } else {
         // This is a string identifier for the addon.
         $parts = explode('-', $slug, 3);
         $key = val(0, $parts);
         if (is_numeric($key)) {
             $addon = $this->getID($key, false, ['GetVersions' => $getVersions]);
         } else {
             $type = strtolower(val(1, $parts));
             $typeID = val($type, self::$Types, 0);
             $version = val(2, $parts);
             $addon = $this->getID(array($key, $typeID, $version), false, ['GetVersions' => $getVersions]);
         }
     }
     if (!$addon) {
         return false;
     }
     $addon['Releases'] = [];
     $addon['Prereleases'] = [];
     if ($getVersions) {
         $maxVersion = valr('Versions.0', $addon);
         $foundMax = false;
         $viewingVersion = false;
         if (is_array(val('Versions', $addon))) {
             foreach ($addon['Versions'] as $version) {
                 // Find the version we are looking at.
                 $versionSlug = AddonModel::slug($addon, $version);
                 if ($versionSlug == $slug && $viewingVersion === false) {
                     $viewingVersion = $version;
                 }
                 // Separate releases & prereleases.
                 if (AddonModel::isReleaseVersion($version['Version'])) {
                     $addon['Releases'][] = $version;
                     // Find the latest stable version.
                     if (!$foundMax) {
                         $maxVersion = $version;
                         $foundMax = true;
                     }
                 } elseif ($foundMax === false) {
                     // Only list prereleases new than the current stable.
                     $addon['Prereleases'][] = $version;
                 }
             }
         }
         if ($viewingVersion === false) {
             $viewingVersion = $maxVersion;
         }
         $addon['CurrentAddonVersionID'] = $maxVersion['AddonVersionID'];
         $addon = array_merge($addon, (array) $viewingVersion);
         $addon['Slug'] = AddonModel::slug($addon, $viewingVersion);
     }
     return $addon;
 }
예제 #5
0
$Access = $this->data('Slug') ? urlencode($this->data('Slug')) : $AddonID;
?>
    <description><?php 
echo Gdn_Format::text($this->Head->title());
?>
</description>
    <language><?php 
echo c('Garden.Locale', 'en-US');
?>
</language>
    <atom:link href="<?php 
echo url('/addon/' . $Access . '/follow.rss');
?>
" rel="self" type="application/rss+xml" />
<?php 
$SlugBase = AddonModel::slug($this->Data, FALSE);
foreach ($this->data('Versions') as $Version) {
    $VersionSlug = urlencode($SlugBase . '-' . $Version['Version']);
    ?>
    <item>
        <title><?php 
    echo Gdn_Format::text($this->data('Name') . ' ' . $Version['Version']);
    ?>
</title>
        <link><?php 
    echo url('/addon/' . $VersionSlug, TRUE);
    ?>
</link>
        <pubDate><?php 
    echo date(DATE_RSS, Gdn_Format::toTimeStamp($Version['DateInserted']));
    ?>
예제 #6
0
/**
 *
 *
 * @param $Addon
 * @param $Alt
 */
function writeAddon($Addon, $Alt)
{
    $Url = '/addon/' . AddonModel::slug($Addon, FALSE);
    ?>
    <li class="Item AddonRow<?php 
    echo $Alt;
    ?>
">
        <?php 
    if ($Addon->Icon != '') {
        echo '<a class="Icon" href="' . url($Url) . '"><div class="IconWrap"><img src="' . Gdn_Upload::url($Addon->Icon) . '" /></div></a>';
    }
    ?>
        <div class="ItemContent">
            <?php 
    echo anchor(htmlspecialchars($Addon->Name), $Url, 'Title');
    echo '<div class="Description">', anchor(htmlspecialchars(sliceString(Gdn_Format::text($Addon->Description), 300)), $Url), '</div>';
    ?>
            <div class="Meta">
                <span class="TypeTag"><?php 
    echo $Addon->Type;
    ?>
</span>
                <?php 
    if ($Addon->Type === 'Locale') {
        ?>
                    <?php 
        if (!is_null($Addon->EnName)) {
            ?>
                <span class="EnName">
                    Name (en)
                    <span><?php 
            echo htmlspecialchars($Addon->EnName);
            ?>
</span>
                </span>
                    <?php 
        }
        ?>
                    <?php 
        if (!is_null($Addon->PercentComplete)) {
            ?>
                <span class="PercentComplete">
                    Translated
                    <span><?php 
            echo (int) $Addon->PercentComplete . '%';
            ?>
</span>
                </span>
                    <?php 
        }
        ?>
                <?php 
    } else {
        ?>
                <span class="Version">
                    Version
                    <span><?php 
        echo htmlspecialchars($Addon->Version);
        ?>
</span>
                </span>
                <?php 
    }
    ?>
                <span class="Author">
                    Author
                    <span><?php 
    echo val('Official', $Addon) ? t('Vanilla Staff') : htmlspecialchars($Addon->InsertName);
    ?>
</span>
                </span>
                <span class="Downloads">
                    Downloads
                    <span><?php 
    echo number_format($Addon->CountDownloads);
    ?>
</span>
                </span>
                <span class="Updated">
                    Updated
                    <span><?php 
    echo Gdn_Format::date($Addon->DateUpdated, 'html');
    ?>
</span>
                </span>
            </div>
        </div>
    </li>
<?php 
}
예제 #7
0
파일: addon.php 프로젝트: vanilla/community
 }
 ?>
     </div>
 <?php 
 if ($addonType && $addonType != 'Core') {
     $typeHelp = t('AddonHelpFor' . $addonType, '');
     if ($typeHelp) {
         echo '<div class="Help">' . $typeHelp . '</div>';
     }
 }
 if ($this->data('Icon') != '') {
     echo '<img class="Icon" src="' . Gdn_Upload::url($this->data('Icon')) . '" itemprop="image" />';
 }
 $currentVersion = $this->data('CurrentVersion');
 if ($currentVersion && $currentVersion != $this->data('Version')) {
     echo '<p>', sprintf(t("This is not the most recent version of this plugin.", 'This is not the most recent version of this plugin. For the most recent version click <a href="%s">here</a>.'), URL('addon/' . AddonModel::Slug($this->Data, false))), '</p>';
 }
 echo '<div itemprop="description">';
 echo Gdn_Format::html($this->data('Description'));
 if ($this->data('Description2') && $ver != 'v1') {
     echo '<br /><br />', Gdn_Format::markdown($this->data('Description2'));
 }
 echo '</div>';
 ?>
 </div>
 <?php 
 if ($this->PictureData->numRows() > 0) {
     ?>
     <div class="PictureBox">
         <?php 
     foreach ($this->PictureData->result() as $picture) {