Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sat, Jul 19, 4:38 AM

in-portal

Index: branches/unlabeled/unlabeled-1.1.2/category_update.php
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/category_update.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.1.2/category_update.php (revision 4123)
@@ -0,0 +1,67 @@
+<?php
+
+$start = getmicrotime();
+
+define('FULL_PATH', realpath(dirname(__FILE__)));
+define('APPLICATION_CLASS', 'MyApplication');
+include_once(FULL_PATH.'/kernel/kernel4/startup.php');
+
+$application =& kApplication::Instance();
+$application->Init();
+
+$conn =& $application->GetADODBConnection();
+
+$sql = 'SELECT CategoryId, ResourceId FROM '.$application->getUnitOption('c', 'TableName');
+$cat_ids = $conn->Query($sql);
+if($cat_ids)
+{
+ $product_list =& $application->recallObject('p', 'p_List', Array('autoload' => false, 'per_page' => 1));
+ foreach($cat_ids as $category_data)
+ {
+ $application->SetVar('m_cat_id', $category_data['CategoryId']);
+ $application->SetVar('c_id', $category_data['CategoryId']);
+ $product_list->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.CategoryId = '.$category_data['CategoryId'] );
+ $product_list->Query(true);
+ $product_list->GoFirst();
+
+ $image = $product_list->GetDBField('LocalPath');
+ if($image)
+ {
+ $sql = 'SELECT ImageId
+ FROM '.$application->getUnitOption('catimg', 'TableName').'
+ WHERE ResourceId = '.$category_data['ResourceId'].'
+ AND DefaultImg = 1';
+ $image_id = $conn->GetOne($sql);
+ if($image_id)
+ {
+ $sql = 'UPDATE '.$application->getUnitOption('catimg', 'TableName').'
+ SET LocalImage = '.$conn->qstr($image).'
+ WHERE ImageId = '.$image_id;
+ }
+ else
+ {
+ $sql = 'INSERT INTO '.$application->getUnitOption('catimg', 'TableName').'
+ VALUES (\'\', '.$category_data['ResourceId'].', \'\', \'Main\', \'Main\', 1, 1, '.$conn->qstr($image).', 1, 1, \'\', 0, '.$conn->qstr($image).', 1, 0)';
+ }
+
+ $conn->ChangeQuery($sql);
+ }
+ }
+}
+
+$end = getmicrotime();
+
+if ( $application->isDebugMode() )
+{
+ echo '<br><br><div style="font-family: arial,verdana; font-size: 8pt;">Memory used: '.round(memory_get_usage()/1024/1024, 1).' Mb <br>';
+ echo 'Time used: '.round(($end - $start), 5).' Sec <br></div>';
+}
+
+//print_pre(get_included_files());
+
+function getmicrotime()
+{
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+}
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/category_update.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1.2.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline