Пример #1
0
 public function __construct(array $instance = NULL)
 {
     parent::__construct();
     $this->optionsArrayName = 'widget_' . erpDefaults::erpWidgetOptionsArrayName;
     $this->defaults = erpDefaults::$widOpts + erpDefaults::$comOpts;
     if ($instance !== NULL && !empty($instance)) {
         $this->options = $instance;
     } else {
         $this->options = $this->defaults;
     }
 }
Пример #2
0
 /**
  * Deletes a single option from options array in DB
  *
  * @param string $optionName
  *        	Option name
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 2.0.0
  */
 public function deleteOption($optionName)
 {
     if ($this->optionsArrayName === NULL) {
         return FALSE;
     }
     $value = parent::deleteOption($optionName);
     if ($value !== NULL) {
         if (update_option($this->optionsArrayName, $this->options)) {
             return TRUE;
         }
         $this->options[$optionName] = $value;
     }
     return FALSE;
 }
Пример #3
0
 /**
  * Set positions based on options (content)
  *
  * @param array $options
  *        	Assoc array
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 2.0.0
  */
 private function setPositions($options)
 {
     if (!$this->options->getContentPositioning() || !is_array($this->options->getContentPositioning())) {
         $this->positions[0] =& $this->thumbnail;
         $this->positions[1] =& $this->title;
         $this->positions[2] =& $this->excerpt;
     } else {
         foreach ($this->options->getContentPositioning() as $k => $v) {
             if ($v == 'title') {
                 $this->positions[$k] =& $this->title;
             } elseif ($v == 'thumbnail') {
                 $this->positions[$k] =& $this->thumbnail;
             } elseif ($v == 'excerpt') {
                 $this->positions[$k] =& $this->excerpt;
             }
         }
     }
 }
Пример #4
0
 /**
  * Calculates weights based on options
  *
  * @return array Assoc array (categories,tags,clicks)
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 2.0.0
  */
 private function calcWeights()
 {
     return isset(erpDefaults::$fetchByOptionsWeights[$this->options->getFetchBy()]) ? erpDefaults::$fetchByOptionsWeights[$this->options->getFetchBy()] : erpDefaults::$fetchByOptionsWeights['categories'];
 }
Пример #5
0
 public function formPostData(WP_Query $wpq, erpOptions $optionsObj, $ratings = array())
 {
     erpPaths::requireOnce(erpPaths::$erpPostData);
     $data = array('title' => $optionsObj->getValue('title'), 'options' => $this->options, 'uniqueID' => $this->uniqueID, 'optionsObj' => $optionsObj, 'posts' => array());
     while ($wpq->have_posts()) {
         $wpq->the_post();
         $rating = isset($ratings[get_the_ID()]) ? $ratings[get_the_ID()] : null;
         $postData = new erpPostData($wpq->post, $optionsObj, $rating);
         if ($optionsObj->haveToShowExcerpt()) {
             $postData->setExcerpt($optionsObj->getValue('excLength'), $optionsObj->getValue('moreTxt'));
         }
         if ($optionsObj->haveToShowThumbnail()) {
             $postData->setThumbnail($optionsObj->getDefaultThumbnail());
         }
         array_push($data['posts'], $postData);
     }
     wp_reset_postdata();
     $this->setAdditionalViewData(array_merge($data, $this->options));
     return $this;
 }