Skip to content

Commit

Permalink
adjust setting page
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiofx committed Dec 2, 2010
1 parent 14451e3 commit d8c2619
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 35 deletions.
8 changes: 3 additions & 5 deletions application/modules/admin/controllers/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,14 @@ public function cleancacheAction()
public function analitycsAction()
{

$end_date = date('Y-m-d');
$id = 'Analytics_date_'.$end_date;
$id = $this->urlAdapter->cleanURL($id);
$id = 'Analytics';

if(!($data = $this->cache->load($id)))
{

$gapi = new Admin_Model_gapi();
$gapi = new Admin_Model_gapi($this->SettingsModel->get('analitycs_username'), $this->SettingsModel->get('analitycs_password'));

$gapi->requestReportData(21731193,array('date'),array('visits', 'visitors'), '-date', '', date('Y-m-d', strtotime('-12 month')), date('Y-m-d'), 1, 600);
$gapi->requestReportData($this->SettingsModel->get('analitycs_id'),array('date'),array('visits', 'visitors'), '-date', '', date('Y-m-d', strtotime('-12 month')), date('Y-m-d'), 1, 600);
// requestReportData($report_id, $dimensions, $metrics, $sort_metric=null, $filter=null, $start_date=null, $end_date=null, $start_index=1, $max_results=30)

$cvs= "Date,visits,visitors \n";
Expand Down
29 changes: 10 additions & 19 deletions application/modules/admin/controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public function init()


// Setting model
$SettingsModel = new Admin_Model_DbTable_SettingsTable();
$this->view->setting_sitetitle = $SettingsModel->get('sitetitle');
$this->view->SettingsModel = new Admin_Model_DbTable_SettingsTable();
$this->view->setting_sitetitle = $this->view->SettingsModel->get('sitetitle');


//models



Expand All @@ -63,26 +65,15 @@ public function preDispatch()

public function indexAction()
{
// action body
$settingForm = new Admin_Form_SettingGeneral();
$settingModel = new Admin_Model_DbTable_SettingsTable();
$request = $this->getRequest();

if ($this->getRequest()->isPost()) {
if ($settingForm->isValid($request->getPost())) {
//Zend_Debug::dump($settingForm->getValues());
$settingModel->updateSetting($settingForm->getValues());

$this->_redirect('/admin/settings');
}
} else {
$result = $settingModel->getAllSettingGeneral();
//Zend_Debug::dump($result);
$settingForm->populate($result);
}


$this->view->settingForm = $settingForm;


$this->view->SettingsModel->updateAll($request->getPost());
$this->_redirect('/admin/settings');
}


}

Expand Down
53 changes: 53 additions & 0 deletions application/modules/admin/models/DbTable/SettingsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,59 @@ public function get($what)



public function updateAll($setting)
{



$data = array('setting_value'=> $setting['sitetitle'],);
$where = $this->getAdapter()->quoteInto('setting_name = ?', 'sitetitle');
$this->update($data , $where );

$data = array('setting_value'=> $setting['tagline'],);
$where = $this->getAdapter()->quoteInto('setting_name = ?', 'tagline');
$this->update($data , $where );

$data = array('setting_value'=> $setting['address'],);
$where = $this->getAdapter()->quoteInto('setting_name = ?', 'address');
$this->update($data , $where );

$data = array('setting_value'=> $setting['emailaddress'],);
$where = $this->getAdapter()->quoteInto('setting_name = ?', 'emailaddress');
$this->update($data , $where );

$data = array('setting_value'=> $setting['analitycs_id'],);
$where = $this->getAdapter()->quoteInto('setting_name = ?', 'analitycs_id');
$this->update($data , $where );

$data = array('setting_value'=> $setting['analitycs_username'],);
$where = $this->getAdapter()->quoteInto('setting_name = ?', 'analitycs_username');
$this->update($data , $where );

$data = array('setting_value'=> $setting['analitycs_password'],);
$where = $this->getAdapter()->quoteInto('setting_name = ?', 'analitycs_password');
$this->update($data , $where );



//cache
if(extension_loaded('apc') == 1)
{ // clean all records
$this->cache->clean(Zend_Cache::CLEANING_MODE_ALL);

}
else
{
$this->cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($this->_name));
$this->cache->clean(Zend_Cache::CLEANING_MODE_OLD);
}
//end cache


}






Expand Down
55 changes: 53 additions & 2 deletions application/modules/admin/views/scripts/settings/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,65 @@
</ul>


<h1>General Settings</h1>
<h1>Settings</h1>


<div id="sinistra">

<form id="form1" name="form1" method="post" action="">

<h3>General Settings</h3>
<table width="100%" border="0">
<tr>
<td width="200">Site Title:</td>
<td>
<input name="sitetitle" type="text" id="sitetitle" value="<?= $this->SettingsModel->get('sitetitle'); ?>" size="50" /></td>
</tr>
<tr>
<td>Tagline:</td>
<td>
<input name="tagline" type="text" id="tagline" value="<?= $this->SettingsModel->get('tagline'); ?>" size="50" /></td>
</tr>
<tr>
<td>Site address (URL):</td>
<td>
<input name="address" type="text" id="address" value="<?= $this->SettingsModel->get('address'); ?>" size="50" /></td>
</tr>
<tr>
<td>E-mail address:</td>
<td>
<input name="emailaddress" type="text" id="emailaddress" value="<?= $this->SettingsModel->get('emailaddress'); ?>" size="50" /></td>
</tr>
</table>

<br />
<h3>Analityc Settings</h3>

<table width="100%" border="0">
<tr>
<td width="200">Id site:</td>
<td>
<input name="analitycs_id" type="text" id="analitycs_id" value="<?= $this->SettingsModel->get('analitycs_id'); ?>" size="50" /></td>
</tr>
<tr>
<td>Username:</td>
<td>
<input name="analitycs_username" type="text" id="analitycs_username" value="<?= $this->SettingsModel->get('analitycs_username'); ?>" size="50" /></td>
</tr>
<tr>
<td>Password:</td>
<td>
<input name="analitycs_password" type="password" id="analitycs_password" value="<?= $this->SettingsModel->get('analitycs_password'); ?>" size="50" /></td>
</tr>
</table>



<input type="submit" name="button" id="button" value="Save" />
<?= $this->button('#button'); ?>

</form>

<?= $this->settingForm; ?>

</div>

Expand Down
42 changes: 33 additions & 9 deletions meme.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-- phpMyAdmin SQL Dump
-- version 3.2.0.1
-- version 3.2.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generato il: 28 nov, 2010 at 07:48 PM
-- Versione MySQL: 5.1.37
-- Versione PHP: 5.2.10
-- Generato il: 02 dic, 2010 at 08:33 PM
-- Versione MySQL: 5.1.44
-- Versione PHP: 5.3.2

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

Expand Down Expand Up @@ -33,13 +33,14 @@ CREATE TABLE `meme_category` (
`category_type` int(11) unsigned NOT NULL,
`category_user_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`category_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dump dei dati per la tabella `meme_category`
--

INSERT INTO `meme_category` VALUES(1, 1, 'First Category', 'first_category', 0, 1);
INSERT INTO `meme_category` VALUES(2, 3, 'kljhjhj', 'kljhjhj', 0, 1);

-- --------------------------------------------------------

Expand Down Expand Up @@ -274,12 +275,17 @@ CREATE TABLE `meme_products` (
`product_user` int(11) unsigned NOT NULL,
`product_url` varchar(255) NOT NULL,
PRIMARY KEY (`product_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

--
-- Dump dei dati per la tabella `meme_products`
--

INSERT INTO `meme_products` VALUES(1, 'lkjlkj', '', '', '', 1291158720, 1, '');
INSERT INTO `meme_products` VALUES(2, 'lkjlkj', '', '', '', 1291158840, 1, '');
INSERT INTO `meme_products` VALUES(3, 'lkjlkj', '', '', '', 1291158900, 1, '');
INSERT INTO `meme_products` VALUES(4, 'jkhkhb', '', '', '', 1291159140, 1, 'jkhkhb');
INSERT INTO `meme_products` VALUES(5, 'lkjljkhljkhl', '', '', '', 1291159320, 1, 'lkjljkhljkhl');

-- --------------------------------------------------------

Expand Down Expand Up @@ -317,12 +323,27 @@ CREATE TABLE `meme_products_value` (
`product_attribute_id` int(11) NOT NULL,
`product_value` mediumtext NOT NULL,
PRIMARY KEY (`product_value_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;

--
-- Dump dei dati per la tabella `meme_products_value`
--

INSERT INTO `meme_products_value` VALUES(1, 1, 1, '');
INSERT INTO `meme_products_value` VALUES(2, 1, 2, '');
INSERT INTO `meme_products_value` VALUES(3, 1, 3, '');
INSERT INTO `meme_products_value` VALUES(4, 2, 1, '');
INSERT INTO `meme_products_value` VALUES(5, 2, 2, '');
INSERT INTO `meme_products_value` VALUES(6, 2, 3, '');
INSERT INTO `meme_products_value` VALUES(7, 3, 1, '');
INSERT INTO `meme_products_value` VALUES(8, 3, 2, '');
INSERT INTO `meme_products_value` VALUES(9, 3, 3, '');
INSERT INTO `meme_products_value` VALUES(10, 4, 1, '');
INSERT INTO `meme_products_value` VALUES(11, 4, 2, '');
INSERT INTO `meme_products_value` VALUES(12, 4, 3, '');
INSERT INTO `meme_products_value` VALUES(13, 5, 1, 'jknljn');
INSERT INTO `meme_products_value` VALUES(14, 5, 2, 'lkjjknlkj');
INSERT INTO `meme_products_value` VALUES(15, 5, 3, '');

-- --------------------------------------------------------

Expand All @@ -335,16 +356,19 @@ CREATE TABLE `meme_settings` (
`setting_name` varchar(255) NOT NULL,
`setting_value` varchar(255) NOT NULL,
PRIMARY KEY (`setting_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

--
-- Dump dei dati per la tabella `meme_settings`
--

INSERT INTO `meme_settings` VALUES(1, 'sitetitle', 'Meme CMS');
INSERT INTO `meme_settings` VALUES(2, 'address', 'http://localhost:8888');
INSERT INTO `meme_settings` VALUES(2, 'address', 'http://memecms.com');
INSERT INTO `meme_settings` VALUES(3, 'emailaddress', 'info@memecms.com');
INSERT INTO `meme_settings` VALUES(4, 'tagline', 'memecms framework RAD');
INSERT INTO `meme_settings` VALUES(5, 'analitycs_id', '');
INSERT INTO `meme_settings` VALUES(6, 'analitycs_username', '');
INSERT INTO `meme_settings` VALUES(7, 'analitycs_password', '');

-- --------------------------------------------------------

Expand Down

0 comments on commit d8c2619

Please sign in to comment.