Author: tkoomzaaskz
Date: 2010-09-11 14:02:49 +0200 (Sat, 11 Sep 2010)
New Revision: 30884
Modified:
plugins/tdCorePlugin/trunk/lib/model/doctrine/PlugintdSubpage.class.php
plugins/tdCorePlugin/trunk/lib/model/doctrine/PlugintdSubpageTable.class.php
plugins/tdCorePlugin/trunk/lib/tdTools.class.php
plugins/tdCorePlugin/trunk/modules/tdConfig/config/generator.yml
plugins/tdCorePlugin/trunk/modules/tdSubpage/actions/actions.class.php
plugins/tdCorePlugin/trunk/modules/tdSubpage/config/generator.yml
Log:
[td][core] - preparing for new release - fixing AJAX actions
Modified:
plugins/tdCorePlugin/trunk/lib/model/doctrine/PlugintdSubpage.class.php
===================================================================
--- plugins/tdCorePlugin/trunk/lib/model/doctrine/PlugintdSubpage.class.php
2010-09-11 11:21:36 UTC (rev 30883)
+++ plugins/tdCorePlugin/trunk/lib/model/doctrine/PlugintdSubpage.class.php
2010-09-11 12:02:49 UTC (rev 30884)
@@ -31,4 +31,32 @@
{
return strip_tags(tdTools::getMbShortenedString($this->getContent(), 400));
}
-}
\ No newline at end of file
+
+ /**
+ * Returns subpage title used as HTML/title.
+ *
+ * @return String - subpage title.
+ */
+ public function getTitle()
+ {
+ return tdTools::getProjectName().' - '.$this->getName();
+ }
+
+ /**
+ * Activates subpage (and saves itself afterwards).
+ */
+ public function activate()
+ {
+ $this->setActive(true);
+ $this->save();
+ }
+
+ /**
+ * Deactivates subpage (and saves itself afterwards).
+ */
+ public function deactivate()
+ {
+ $this->setActive(false);
+ $this->save();
+ }
+}
Modified:
plugins/tdCorePlugin/trunk/lib/model/doctrine/PlugintdSubpageTable.class.php
===================================================================
---
plugins/tdCorePlugin/trunk/lib/model/doctrine/PlugintdSubpageTable.class.php
2010-09-11 11:21:36 UTC (rev 30883)
+++
plugins/tdCorePlugin/trunk/lib/model/doctrine/PlugintdSubpageTable.class.php
2010-09-11 12:02:49 UTC (rev 30884)
@@ -7,13 +7,39 @@
*/
class PlugintdSubpageTable extends Doctrine_Table
{
- /**
- * Returns an instance of this class.
- *
- * @return object PlugintdSubpageTable
- */
- public static function getInstance()
- {
- return Doctrine_Core::getTable('PlugintdSubpage');
- }
-}
\ No newline at end of file
+ /**
+ * Returns an instance of this class.
+ *
+ * @return object PlugintdSubpageTable
+ */
+ public static function getInstance()
+ {
+ return Doctrine_Core::getTable('PlugintdSubpage');
+ }
+
+ /**
+ * Returns a query retrieving a subpage given by the id.
+ *
+ * @param Integer $id - subpage id.
+ * @return Doctrine_Query - query retrieving a subpage.
+ */
+ public function getActiveSubpageByIdQuery($id)
+ {
+ return $this->createQuery('s')
+ ->where('s.active = 1')
+ ->andWhere('s.id = ?', $id);
+ }
+
+ /**
+ * Returns query retrieving subpage given by id.
+ *
+ * @param Integer $id - subpage id.
+ * @return Doctrine_Query - query retrieving subpage given by id.
+ */
+ static public function getSubpageByIdQuery($id)
+ {
+ return Doctrine_Query::create()
+ ->from('tdSubpage s')
+ ->where('s.id = ?', $id);
+ }
+}
Modified: plugins/tdCorePlugin/trunk/lib/tdTools.class.php
===================================================================
--- plugins/tdCorePlugin/trunk/lib/tdTools.class.php 2010-09-11 11:21:36 UTC
(rev 30883)
+++ plugins/tdCorePlugin/trunk/lib/tdTools.class.php 2010-09-11 12:02:49 UTC
(rev 30884)
@@ -10,15 +10,27 @@
*/
class tdTools
{
- /**
- * Returns mb shortened string to a given limit
- *
- * @param String $content - raw string value to shorten
- * @param Integer $limit - limited length of shortened string
- * @return String - mb shortened string
- */
- public static function getMbShortenedString($content, $limit)
- {
- return mb_strlen($content) > $limit ? mb_substr($content, 0,
$limit).'...' : $content;
- }
+ /**
+ * Returns mb shortened string to a given limit.
+ *
+ * @param String $content - raw string value to shorten
+ * @param Integer $limit - limited length of shortened string
+ * @return String - mb shortened string
+ */
+ static public function getMbShortenedString($content, $limit)
+ {
+ return mb_strlen($content) > $limit ? mb_substr($content, 0, $limit) .
'...' : $content;
+ }
+
+ /**
+ * Returns project name, defined in config/properties.ini file.
+ *
+ * @return String - project name
+ */
+ static public function getProjectName()
+ {
+ $file = sfConfig::get('sf_config_dir').'/properties.ini';
+ $content = parse_ini_file($file, true);
+ return $content['symfony']['name'];
+ }
}
Modified: plugins/tdCorePlugin/trunk/modules/tdConfig/config/generator.yml
===================================================================
--- plugins/tdCorePlugin/trunk/modules/tdConfig/config/generator.yml
2010-09-11 11:21:36 UTC (rev 30883)
+++ plugins/tdCorePlugin/trunk/modules/tdConfig/config/generator.yml
2010-09-11 12:02:49 UTC (rev 30884)
@@ -10,7 +10,7 @@
route_prefix: tdConfig
with_doctrine_route: true
actions_base_class: sfActions
-# css: td_admin
+ css: td_admin
config:
actions: ~
Modified: plugins/tdCorePlugin/trunk/modules/tdSubpage/actions/actions.class.php
===================================================================
--- plugins/tdCorePlugin/trunk/modules/tdSubpage/actions/actions.class.php
2010-09-11 11:21:36 UTC (rev 30883)
+++ plugins/tdCorePlugin/trunk/modules/tdSubpage/actions/actions.class.php
2010-09-11 12:02:49 UTC (rev 30884)
@@ -21,10 +21,10 @@
*/
public function executeActivate(sfWebRequest $request)
{
- $subpage =
SubpageTable::getSubpageByIdQuery($request->getParameter('id'))->fetchOne();
- $subpage->activate();
+ $td_subpage =
tdSubpageTable::getSubpageByIdQuery($request->getParameter('id'))->fetchOne();
+ $td_subpage->activate();
- return $this->renderPartial('subpage/ajax_deactivate', array('subpage' =>
$subpage));
+ return $this->renderPartial('tdSubpage/ajax_deactivate',
array('td_subpage' => $td_subpage));
}
/**
@@ -35,9 +35,9 @@
*/
public function executeDeactivate(sfWebRequest $request)
{
- $subpage =
SubpageTable::getSubpageByIdQuery($request->getParameter('id'))->fetchOne();
- $subpage->deactivate();
+ $td_subpage =
tdSubpageTable::getSubpageByIdQuery($request->getParameter('id'))->fetchOne();
+ $td_subpage->deactivate();
- return $this->renderPartial('subpage/ajax_activate', array('subpage' =>
$subpage));
+ return $this->renderPartial('tdSubpage/ajax_activate', array('td_subpage'
=> $td_subpage));
}
}
Modified: plugins/tdCorePlugin/trunk/modules/tdSubpage/config/generator.yml
===================================================================
--- plugins/tdCorePlugin/trunk/modules/tdSubpage/config/generator.yml
2010-09-11 11:21:36 UTC (rev 30883)
+++ plugins/tdCorePlugin/trunk/modules/tdSubpage/config/generator.yml
2010-09-11 12:02:49 UTC (rev 30884)
@@ -10,7 +10,7 @@
route_prefix: tdSubpage
with_doctrine_route: true
actions_base_class: sfActions
-# css: td_admin
+ css: td_admin
config:
actions: ~
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.