예제 #1
0
파일: create.php 프로젝트: rcclaudrey/dev
    /*
    	$params = isset($argv)
    		? Vikont_Pulliver_Helper_Data::getCommandLineParams($argv)
    		: new Varien_Object($_GET);
    
    	Mage::register('pulliver_params', $params);
    	$downloadedFileName = $params->getData('use_downloaded_file');
    
    
    	Vikont_Pulliver_Helper_Data::inform(sprintf('Successfully created file %s, %d lines processed, %d lines added',
    			$outputFileName,
    			count($update),
    			$lineCounter
    		));
    /**/
    $am = new AttributeManager();
    // first we need to create the attributes themselves:
    $am->createAttributes($attributes);
    // ...and their options as well, if needed:
    //	$am->addAttributeOptions('attr_code', $attrOptionValues);
    // now, for each attribute set, we need to:
    // create the attribute set:
    //	$am->addAttributeSet(CPET, 'attr set name1');
    // add tabbed attr groups to that set:
    //	$am->addAttributeGroupToSet('attr set name', $attributeTabs);
    //	addAttributeGroupToSet('attr set name1', $baseTabs);
    //	addAttributeGroupToSet('attr set name1', $commonTabs);
    //	addAttributeGroupToSet('attr set name1', $customTabs1);
    // this should be repeated for each attribute set
} catch (Exception $e) {
    Mage::logException($e);
예제 #2
0
 function parseSelectionWP($ast, $name, $header)
 {
     // Push LibraryManager so we can undo this waypoint's definitions.
     ob_start();
     LibraryManager::Push();
     $res = new GenerationInfo();
     /***************   PROCESS AST   ***************/
     $attMap = parseAttributeMap(ast_get($ast, NodeKey::ATT_MAP), $res);
     $qFilters = ast_get($ast, NodeKey::FILTERS);
     $qSynth = ast_get($ast, NodeKey::SYNTH);
     $queries = [];
     foreach ($qFilters as $query => $qInfo) {
         $filterAST = ast_get($qInfo, NodeKey::ARGS);
         $gfAST = ast_get($qInfo, NodeKey::TYPE);
         if ($gfAST !== null) {
             $filter = parseNamedExpressionList($filterAST);
         } else {
             $filter = parseExpressionList($filterAST);
         }
         $gf = null;
         if ($gfAST !== null) {
             $gf = parseGF($gfAST);
             $gf = $gf->apply($filter);
         }
         if (ast_has($qInfo, NodeKey::CARGS)) {
             $cargs = parseLiteralList(ast_get($qInfo, NodeKey::CARGS));
         } else {
             $cargs = [];
         }
         $sargs = ast_has($qInfo, NodeKey::SARGS) ? parseStateList(ast_get($qInfo, NodeKey::SARGS), $query) : [];
         $synths = array();
         $synthAST = ast_get($ast, NodeKey::SYNTH);
         if (ast_has($synthAST, $query)) {
             $curSynths = ast_get($synthAST, $query);
             foreach ($curSynths as $curSynthAST) {
                 $expr = parseExpression(ast_get($curSynthAST, NodeKey::EXPR));
                 $att = parseAttribute(ast_get($curSynthAST, NodeKey::ATT));
                 if ($att->type() == null) {
                     AttributeManager::setAttributeType($att->name(), $expr->type());
                     $att = AttributeManager::lookupAttribute($att->name());
                 } else {
                     if (canConvert($expr, $att->type())) {
                         $expr = convertExpression($expr, $att->type());
                     } else {
                         grokit_error('Unable to convert expression for synthesized attribute ' . $att->name() . ' from type ' . $expr->type() . ' to type ' . $att->type() . ' ' . $expr->source());
                     }
                 }
                 $synths[$att->name()] = $expr;
             }
         }
         $info = ['filters' => $filter, 'synths' => $synths, 'gf' => $gf, 'cargs' => $cargs, 'states' => $sargs];
         $queries[$query] = $info;
         $res->addJob($query, $name);
         $res->absorbInfoList($filter);
         $res->absorbInfoList($synths);
         $res->absorbInfoList($cargs);
         $res->absorbStateList($sargs);
         if ($gf !== null) {
             $res->absorbInfo($gf);
         }
     }
     /*************** END PROCESS AST ***************/
     // Get this waypoint's headers
     $myHeaders = $header . PHP_EOL . ob_get_clean();
     // Only one file at the moment
     $filename = $name . '.cc';
     $res->addFile($filename, $name);
     _startFile($filename);
     SelectionGenerate($name, $queries, $attMap);
     _endFile($filename, $myHeaders);
     // Pop LibraryManager again to get rid of this waypoint's declarations
     LibraryManager::Pop();
     return $res;
 }