Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Welch committed Feb 12, 2017
2 parents b4ca940 + 83a7372 commit 370723e
Show file tree
Hide file tree
Showing 14 changed files with 381 additions and 147 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# SEOmatic Changelog

## 1.1.42 -- 2017.02.12

* [Fixed] Fixed a regression that could cause FieldTypes to not save properly
* [Improved] Moved the lattitude/longitude info down below the address information for on the Site Identity & Site Creator settings
* [Improved] Wrapped all `templates->render()` calls in try/catch blocks to more gracefully handle errors
* [Added] Added an `Anonymize IP` toggle for Google Analytics, for compliance with some local laws
* [Added] Added Wikipedia to the Social Media settings & `sameAs` entity information

## 1.1.41 -- 2017.02.10

* [Improved] Broke the changelog out to CHANGELOG.md
Expand Down
4 changes: 2 additions & 2 deletions SeomaticPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public function getReleaseFeedUrl()

public function getVersion()
{
return '1.1.41';
return '1.1.42';
}

public function getSchemaVersion()
{
return '1.1.23';
return '1.1.25';
}

public function getDeveloper()
Expand Down
2 changes: 2 additions & 0 deletions controllers/SeomaticController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ public function actionSaveIdentity()
$record->googleAnalyticsEEcommerce = craft()->request->getPost('googleAnalyticsEEcommerce', $record->googleAnalyticsEEcommerce);
$record->googleAnalyticsLinkAttribution = craft()->request->getPost('googleAnalyticsLinkAttribution', $record->googleAnalyticsLinkAttribution);
$record->googleAnalyticsLinker = craft()->request->getPost('googleAnalyticsLinker', $record->googleAnalyticsLinker);
$record->googleAnalyticsAnonymizeIp = craft()->request->getPost('googleAnalyticsAnonymizeIp', $record->googleAnalyticsAnonymizeIp);
$record->siteOwnerType = craft()->request->getPost('siteOwnerType', $record->siteOwnerType);
$record->siteOwnerSubType = craft()->request->getPost('siteOwnerSubType', $record->siteOwnerSubType);
$record->siteOwnerSpecificType = craft()->request->getPost('siteOwnerSpecificType', $record->siteOwnerSpecificType);
Expand Down Expand Up @@ -1127,6 +1128,7 @@ public function actionSaveSocial()
$record->pinterestHandle = craft()->request->getPost('pinterestHandle', $record->pinterestHandle);
$record->githubHandle = craft()->request->getPost('githubHandle', $record->githubHandle);
$record->vimeoHandle = craft()->request->getPost('vimeoHandle', $record->vimeoHandle);
$record->wikipediaUrl = craft()->request->getPost('wikipediaUrl', $record->wikipediaUrl);

if ($record->save())
{
Expand Down
96 changes: 50 additions & 46 deletions fieldtypes/Seomatic_MetaFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,56 +333,14 @@ public function prepValueFromPost($value)

if (empty($value))
{
$result = $this->prepValue($value);
$value = $this->prepValue($value);
}
else
{
$result = new Seomatic_MetaFieldModel($value);
$result = $this->prepValue($result);
$value = new Seomatic_MetaFieldModel($value);
$value = $this->prepValue($value);
}
return $result;
}

public function prepValue($value)
{
if (!$value)
{
$value = new Seomatic_MetaFieldModel();

$value->seoMainEntityCategory = $this->getSettings()->seoMainEntityCategory;
$value->seoMainEntityOfPage = $this->getSettings()->seoMainEntityOfPage;

$value->seoTitle = $this->getSettings()->seoTitle;
$value->seoTitleUnparsed = $this->getSettings()->seoTitle;
$value->seoTitleSource = $this->getSettings()->seoTitleSource;
$value->seoTitleSourceField = $this->getSettings()->seoTitleSourceField;

$value->seoDescription = $this->getSettings()->seoDescription;
$value->seoDescriptionUnparsed = $this->getSettings()->seoDescription;
$value->seoDescriptionSource = $this->getSettings()->seoDescriptionSource;
$value->seoDescriptionSourceField = $this->getSettings()->seoDescriptionSourceField;

$value->seoKeywords = $this->getSettings()->seoKeywords;
$value->seoKeywordsUnparsed = $this->getSettings()->seoKeywords;
$value->seoKeywordsSource = $this->getSettings()->seoKeywordsSource;
$value->seoKeywordsSourceField = $this->getSettings()->seoKeywordsSourceField;

$value->seoImageIdSource = $this->getSettings()->seoImageIdSource;
$value->seoImageIdSourceField = $this->getSettings()->seoImageIdSourceField;
$value->seoImageTransform = $this->getSettings()->seoImageTransform;

$value->twitterCardType = $this->getSettings()->twitterCardType;
$value->seoTwitterImageIdSource = $this->getSettings()->seoTwitterImageIdSource;
$value->seoTwitterImageIdSourceField = $this->getSettings()->seoTwitterImageIdSourceField;
$value->seoTwitterImageTransform = $this->getSettings()->seoTwitterImageTransform;

$value->openGraphType = $this->getSettings()->openGraphType;
$value->seoFacebookImageIdSource = $this->getSettings()->seoFacebookImageIdSource;
$value->seoFacebookImageIdSourceField = $this->getSettings()->seoFacebookImageIdSourceField;
$value->seoFacebookImageTransform = $this->getSettings()->seoFacebookImageTransform;

$value->robots = $this->getSettings()->robots;
}

/* -- Handle pulling values from other fields */

Expand Down Expand Up @@ -503,7 +461,50 @@ public function prepValue($value)
}

}
return $value;
}

public function prepValue($value)
{

if (!$value)
{
$value = new Seomatic_MetaFieldModel();

$value->seoMainEntityCategory = $this->getSettings()->seoMainEntityCategory;
$value->seoMainEntityOfPage = $this->getSettings()->seoMainEntityOfPage;

$value->seoTitle = $this->getSettings()->seoTitle;
$value->seoTitleUnparsed = $this->getSettings()->seoTitle;
$value->seoTitleSource = $this->getSettings()->seoTitleSource;
$value->seoTitleSourceField = $this->getSettings()->seoTitleSourceField;

$value->seoDescription = $this->getSettings()->seoDescription;
$value->seoDescriptionUnparsed = $this->getSettings()->seoDescription;
$value->seoDescriptionSource = $this->getSettings()->seoDescriptionSource;
$value->seoDescriptionSourceField = $this->getSettings()->seoDescriptionSourceField;

$value->seoKeywords = $this->getSettings()->seoKeywords;
$value->seoKeywordsUnparsed = $this->getSettings()->seoKeywords;
$value->seoKeywordsSource = $this->getSettings()->seoKeywordsSource;
$value->seoKeywordsSourceField = $this->getSettings()->seoKeywordsSourceField;

$value->seoImageIdSource = $this->getSettings()->seoImageIdSource;
$value->seoImageIdSourceField = $this->getSettings()->seoImageIdSourceField;
$value->seoImageTransform = $this->getSettings()->seoImageTransform;

$value->twitterCardType = $this->getSettings()->twitterCardType;
$value->seoTwitterImageIdSource = $this->getSettings()->seoTwitterImageIdSource;
$value->seoTwitterImageIdSourceField = $this->getSettings()->seoTwitterImageIdSourceField;
$value->seoTwitterImageTransform = $this->getSettings()->seoTwitterImageTransform;

$value->openGraphType = $this->getSettings()->openGraphType;
$value->seoFacebookImageIdSource = $this->getSettings()->seoFacebookImageIdSource;
$value->seoFacebookImageIdSourceField = $this->getSettings()->seoFacebookImageIdSourceField;
$value->seoFacebookImageTransform = $this->getSettings()->seoFacebookImageTransform;

$value->robots = $this->getSettings()->robots;
}

if (craft()->request->isSiteRequest())
{
Expand Down Expand Up @@ -538,7 +539,10 @@ public function onAfterElementSave()
// if ($shouldResave)
if (true)
{
$defaultField = $this->prepValue(null);
if ($content)
$defaultField = $this->prepValueFromPost($content[$fieldHandle]);
else
$defaultField = $this->prepValueFromPost(null);
$content->setAttribute($fieldHandle, $defaultField);
$element->setContent($content);
craft()->content->saveContent($element);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
namespace Craft;

/**
* The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName
*/
class m170212_000000_seomatic_addGoogleAnalyticsAnonymizeIp extends BaseMigration
{
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
// specify columns and AttributeType
$newColumns = array (
'googleAnalyticsAnonymizeIp' => ColumnType::Bool,
);

$this->_addColumnsAfter("seomatic_settings", $newColumns, "googleAnalyticsLinker");

// return true and let craft know its done
return true;
}

private function _addColumnsAfter($tableName, $newColumns, $afterColumnHandle)
{

// this is a foreach loop, enough said
foreach ($newColumns as $columnName => $columnType)
{
// check if the column does NOT exist
if (!craft()->db->columnExists($tableName, $columnName))
{
$this->addColumnAfter($tableName, $columnName, array(
'column' => $columnType,
'null' => false,
),
$afterColumnHandle
);

// log that we created the new column
SeomaticPlugin::log("Created the `$columnName` in the `$tableName` table.", LogLevel::Info, true);

}

// if the column already exists in the table
else {

// tell craft that we couldn't create the column as it alredy exists.
SeomaticPlugin::log("Column `$columnName` already exists in the `$tableName` table.", LogLevel::Info, true);

}
}
}
}
58 changes: 58 additions & 0 deletions migrations/m170212_000000_seomatic_addWikipedia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
namespace Craft;

/**
* The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName
*/
class m170212_000000_seomatic_addWikipedia extends BaseMigration
{
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
// specify columns and AttributeType
$newColumns = array (
'wikipediaUrl' => ColumnType::Varchar
);

$this->_addColumnsAfter("seomatic_settings", $newColumns, "vimeoHandle");
$this->alterColumn('seomatic_settings', 'wikipediaUrl', array(ColumnType::Varchar, 'maxLength' => 100));

// return true and let craft know its done
return true;
}

private function _addColumnsAfter($tableName, $newColumns, $afterColumnHandle)
{

// this is a foreach loop, enough said
foreach ($newColumns as $columnName => $columnType)
{
// check if the column does NOT exist
if (!craft()->db->columnExists($tableName, $columnName))
{
$this->addColumnAfter($tableName, $columnName, array(
'column' => $columnType,
'null' => false,
),
$afterColumnHandle
);

// log that we created the new column
SeomaticPlugin::log("Created the `$columnName` in the `$tableName` table.", LogLevel::Info, true);

}

// if the column already exists in the table
else {

// tell craft that we couldn't create the column as it alredy exists.
SeomaticPlugin::log("Column `$columnName` already exists in the `$tableName` table.", LogLevel::Info, true);

}
}
}
}
2 changes: 2 additions & 0 deletions models/Seomatic_SettingsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected function defineAttributes()
'googleAnalyticsEEcommerce' => array(AttributeType::Bool, 'default' => false),
'googleAnalyticsLinkAttribution' => array(AttributeType::Bool, 'default' => false),
'googleAnalyticsLinker' => array(AttributeType::Bool, 'default' => false),
'googleAnalyticsAnonymizeIp' => array(AttributeType::Bool, 'default' => false),
'siteOwnerType' => array(AttributeType::String, 'default' => 'Organization'),
'siteOwnerSubType' => array(AttributeType::String, 'default' => 'Corporation'),
'siteOwnerSpecificType' => array(AttributeType::String, 'default' => ''),
Expand Down Expand Up @@ -114,6 +115,7 @@ protected function defineAttributes()
'pinterestHandle' => array(AttributeType::String, 'default' => ''),
'githubHandle' => array(AttributeType::String, 'default' => ''),
'vimeoHandle' => array(AttributeType::String, 'default' => ''),
'wikipediaUrl' => array(AttributeType::String, 'default' => ''),

/* --------------------------------------------------------------------------------
CEATOR settings
Expand Down
2 changes: 2 additions & 0 deletions records/Seomatic_SettingsRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected function defineAttributes()
'googleAnalyticsEEcommerce' => array(AttributeType::Bool, 'default' => false),
'googleAnalyticsLinkAttribution' => array(AttributeType::Bool, 'default' => false),
'googleAnalyticsLinker' => array(AttributeType::Bool, 'default' => false),
'googleAnalyticsAnonymizeIp' => array(AttributeType::Bool, 'default' => false),
'siteOwnerType' => array(AttributeType::String, 'maxLength' => 50, 'default' => ''),
'siteOwnerSubType' => array(AttributeType::String, 'maxLength' => 50, 'default' => ''),
'siteOwnerSpecificType' => array(AttributeType::String, 'maxLength' => 50, 'default' => ''),
Expand Down Expand Up @@ -118,6 +119,7 @@ protected function defineAttributes()
'pinterestHandle' => array(AttributeType::String, 'maxLength' => 50, 'default' => ''),
'githubHandle' => array(AttributeType::String, 'maxLength' => 50, 'default' => ''),
'vimeoHandle' => array(AttributeType::String, 'maxLength' => 50, 'default' => ''),
'wikipediaUrl' => array(AttributeType::String, 'maxLength' => 100, 'default' => ''),


/* --------------------------------------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
[
{
"version": "1.1.42",
"downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip",
"date": "2017-02-12T11:00:00-11:00",
"notes": [
"[Fixed] Fixed a regression that could cause FieldTypes to not save properly",
"[Improved] Moved the lattitude/longitude info down below the address information for on the Site Identity & Site Creator settings",
"[Improved] Wrapped all `templates->render()` calls in try/catch blocks to more gracefully handle errors",
"[Added] Added an `Anonymize IP` toggle for Google Analytics, for compliance with some local laws",
"[Added] Added Wikipedia to the Social Media settings & `sameAs` entity information"
]
},
{
"version": "1.1.41",
"downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip",
Expand Down
Loading

0 comments on commit 370723e

Please sign in to comment.