Example #1
0
 public function getLineCollection()
 {
     $maxCollectionSize = max(1, $this->mHelper('config')->getLogViewerMaxCollectionSize());
     $regExp = '/(\\d+-\\d+-\\d+T\\d+[0-9\\-+T:]+?)\\s+?([A-Z]+?)\\s+?\\((\\d+)\\)\\:\\s+?(.+?)(?:(?=(?:\\d+-\\d+-\\d+T\\d+[0-9\\-+T:]+?))|$)/si';
     $contents = file_get_contents($this->getPath());
     $lines = array();
     if (preg_match_all($regExp, $contents, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             $lines[] = $match[0];
         }
     }
     $lines = array_reverse($lines);
     $collection = Mage::getModel('ewcore/system_log_file_line_collection');
     foreach ($lines as $line) {
         if ($collection->count() >= $maxCollectionSize) {
             break;
         }
         $line = trim($line);
         if (preg_match($regExp, $line, $match)) {
             list($date, $priorityName, $priority, $message) = array_slice($match, 1);
             $message = trim($message);
             if ($date and $priorityName and $priority and $message) {
                 $item = new Varien_Object();
                 $item->setDate($date);
                 $item->setPriorityName($priorityName);
                 $item->setPriority($priority);
                 $item->setMessage($message);
                 $collection->addItem($item);
             }
         }
     }
     return $collection;
 }
Example #2
0
 protected function _prepareObject(array $data)
 {
     $object = new Varien_Object();
     $object->setId($data['post_id']);
     $object->setUrl($data['url']);
     $object->setDate($data['date']);
     return $object;
 }
Example #3
0
 private function _processPeriod($collection, $period)
 {
     switch ($period) {
         case 'day':
             return $collection;
             break;
         case 'month':
             $index = 1;
             break;
         case 'year':
             $index = 0;
             break;
     }
     $fields = array('abandoned_carts_num', 'abandoned_carts_price', 'abandoned_items_num', 'recovered_carts_num', 'ordered_carts_num', 'ordered_carts_price', 'ordered_items_num', 'av_back_time', 'target_letter_step');
     $date = $collection->getFirstItem()->getDate();
     $dateArray = explode('-', $date);
     $val = $dateArray[$index];
     $returnCollection = new Varien_Data_Collection();
     $object = new Varien_Object();
     //$counterABT=0;
     $counterTLS = 0;
     foreach ($collection as $item) {
         $dateArray = explode('-', $item->getDate());
         if ($dateArray[$index] != $val) {
             $val = $dateArray[$index];
             /*if($counterABT)
               {
                   $object->setData('av_back_time',$object->getData('av_back_time')/$counterABT);
               }*/
             if ($counterTLS) {
                 $object->setData('target_letter_step', $object->getData('target_letter_step') / $counterTLS);
             }
             $returnCollection->addItem($object);
             $object = new Varien_Object();
             $counterABT = 0;
             $counterTLS = 0;
         }
         $object->setDate($item->getDate());
         //if($item->getData('av_back_time'))$counterABT++;
         if ($item->getData('target_letter_step')) {
             $counterTLS++;
         }
         foreach ($fields as $field) {
             $object->setData($field, $object->getData($field) + $item->getData($field));
         }
     }
     /*if($counterABT)
       {
           $object->setData('av_back_time',$object->getData('av_back_time')/$counterABT);
       }*/
     if ($counterTLS) {
         $object->setData('target_letter_step', $object->getData('target_letter_step') / $counterTLS);
     }
     $returnCollection->addItem($object);
     return $returnCollection;
 }