Exemple #1
0
 /**
  * @param array|string $data
  * @param string $defaultLogo
  */
 public function __construct($data, $defaultLogo = null)
 {
     if (is_string($data)) {
         $data = $this->parseStr($data);
     }
     if (!isset($data['type'])) {
         if ($defaultLogo) {
             $data['type'] = self::TYPE_IMAGE;
         } else {
             $data['type'] = self::TYPE_TEXT;
         }
     }
     switch ($data['type']) {
         case self::TYPE_TEXT:
             $this->type = self::TYPE_TEXT;
             break;
         case self::TYPE_IMAGE:
             $this->type = self::TYPE_IMAGE;
             break;
         default:
             $this->type = self::TYPE_TEXT;
             break;
     }
     if (!empty($data['imageOrig']) && file_exists(ipFile('file/repository/' . $data['imageOrig']))) {
         $this->imageOrig = $data['imageOrig'];
         if (isset($data['x1']) && isset($data['y1']) && isset($data['x2']) && isset($data['y2'])) {
             $this->x1 = $data['x1'];
             $this->y1 = $data['y1'];
             $this->x2 = $data['x2'];
             $this->y2 = $data['y2'];
             if (empty($data['requiredWidth'])) {
                 $data['requiredWidth'] = $this->x2 - $this->x1;
             }
             if (empty($data['requiredHeight'])) {
                 $data['requiredHeight'] = $this->y2 - $this->y1;
             }
             $this->requiredWidth = $data['requiredWidth'];
             $this->requiredHeight = $data['requiredHeight'];
             $transform = array('type' => 'crop', 'x1' => $this->getX1(), 'y1' => $this->getY1(), 'x2' => $this->getX2(), 'y2' => $this->getY2(), 'width' => $this->getRequiredWidth(), 'height' => $this->getRequiredHeight(), 'quality' => 100);
             $requestedName = \Ip\Internal\Text\Specialchars::url(ipGetOptionLang('Config.websiteTitle'));
             $this->image = ipReflection($this->getImageOrig(), $transform, $requestedName);
         }
     } else {
         $this->image = $defaultLogo;
     }
     if (!empty($data['text'])) {
         $this->setText($data['text']);
     } else {
         $this->setText(ipGetOptionLang('Config.websiteTitle'));
     }
     if (isset($data['color'])) {
         $this->setColor($data['color']);
     }
     if (isset($data['font'])) {
         $this->setFont($data['font']);
     }
 }
Exemple #2
0
 public static function allocatePathForNewPage(array $page)
 {
     if (array_key_exists('urlPath', $page)) {
         $path = $page['urlPath'];
     } elseif (!empty($page['title'])) {
         $path = $page['title'];
     } else {
         $path = 'page';
     }
     $path = \Ip\Internal\Text\Specialchars::url($path);
     return static::allocatePath($page['languageCode'], $path);
 }
Exemple #3
0
 /**
  * @param $languageCode
  * @param $alias
  * @param $title
  * @param string $type
  * @return int
  */
 public static function createMenu($languageCode, $alias, $title, $type = 'tree')
 {
     $data = array();
     $data['languageCode'] = $languageCode;
     if (empty($alias)) {
         $alias = \Ip\Internal\Text\Specialchars::url($title);
     }
     $data['alias'] = static::allocateUniqueAlias($languageCode, $alias);
     $data['title'] = $title;
     $data['type'] = $type;
     $data['parentId'] = 0;
     $data['pageOrder'] = static::getNextPageOrder(array('languageCode' => $languageCode, 'parentId' => $data['parentId']));
     $data['isVisible'] = 1;
     return self::addPage(0, $data);
 }